Q
将声音添加到滑块
1
A
回答
2
如果您不需要传统浏览器支持,请查看Web Audio API。 https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
这里有一个例子:http://www.html5rocks.com/en/tutorials/webaudio/intro/
//call the init function on window load
window.onload = init;
var context;
var bufferLoader;
//create 2 audio sources... as there were 2 in the example linked above
var source1 = context.createBufferSource();
var source2 = context.createBufferSource();
function init() {
//initialise the audio context
context = new webkitAudioContext();
//init preloading of sounds
bufferLoader = new BufferLoader(
context,
[
'../sounds/br-jam-loop.wav',
'../sounds/laughter.wav',
],
finishedLoading // <- callback function when finished loading
);
bufferLoader.load();
}
function finishedLoading(bufferList) {
//set the buffers of the sources from the loaded bufferlist
source1.buffer = bufferList[0];
source2.buffer = bufferList[1];
//connect the sources to the output
source1.connect(context.destination);
source2.connect(context.destination);
}
然后,您可以使用您的插件回调函数来触发声音,如:
$('#featured').orbit({
afterSlideChange: function(){
source1.noteOn(0);
source2.noteOn(0);
}
});
这样的事情应该做的伎俩。
......这里也有一些框架,它会为你做一些工作。 http://www.schillmania.com/projects/soundmanager2/是一个很好的。
相关问题
- 1. 将DragScroll添加到滑块
- 2. cocos2d的声音滑块?
- 3. 如何将音量滑块添加到android动作栏?
- 4. 向网站添加滑动声音
- 5. 将声音添加到倒计时
- 6. 如何将声音添加到通知?
- 7. 将声音添加到Fortran程序
- 8. 如何将声音添加到通知?
- 9. 将声音添加到Xcode 4.3
- 10. 将文本添加到jQuery滑块
- 11. 将滑块添加到电影中
- 12. 将滑块添加到matplotlib图表
- 13. 将链接添加到滑块横幅
- 14. 如何将滑块添加到QMenu中?
- 15. WPF:将样式添加到滑块
- 16. 延迟添加到声音
- 17. 当value = 0时,将'静音扬声器'图标链接到音量滑块?
- 18. 将声音附加到SKEmitterNode
- 19. AS3播放滑块上的声音值
- 20. 添加声音java
- 21. 将声音静音按钮添加到视频对象
- 22. 音量滑块
- 23. 如何将jquery ui滑块添加到PrestaShop模块表单
- 24. 添加声音到Android系统声音列表
- 25. 添加自定义声音到UILocalNotification声音名
- 26. 如何将自动滑块功能添加到我的jQuery滑块?
- 27. 如何将范围滑块的功能添加到常规滑块中
- 28. jQuery滑块想要添加箭头到我的滑块
- 29. 将拉斯维加斯滑块添加到div背景
- 30. 添加声音到OpenGL应用程序
自动播放声音是一个非常糟糕的主意。 –
尽可能多的,当谈到您的普通网站,声音仍然可以在更多的应用程序/游戏般的情况下很有意义... –