我一直在尝试与音频元件连接到使用createMediaElementSource网络音频API的音频元素上设置playbackRate并得到它的工作,但有一点我需要做的是改变音频播放速度标签,我无法让它工作。连接到网络音频API
如果您尝试运行,下面的代码,你会看到,它的作品,直到您取消注释,我们设置播放速度就行了。当这条线在音频中被静音。
我知道我可以使用source.playbackRate.value在AudioBufferSourceNode上设置回放速度,但这不是我想要做的,我需要在音频元素连接到网络时设置回放速度音频api使用createMediaElementSource,所以我没有任何AudioBufferSourceNode。
有没有人设法做到这一点?
var _source,
_audio,
_context,
_gainNode;
_context = new webkitAudioContext();
function play(url) {
if (_audio) {
_audio.pause();
}
_audio = new Audio(url);
//_audio.playbackRate = 0.6;
setTimeout(function() {
if (!_gainNode) {
_gainNode = _context.createGainNode();
_gainNode.gain.value = 0.1;
_gainNode.connect(_context.destination);
}
_source = _context.createMediaElementSource(_audio);
_source.connect(_gainNode);
_audio.play();
}, 0);
}
play("http://geo-samples.beatport.com/items/volumes/volume2/items/3000000/200000/40000/9000/400/60/3249465.LOFI.mp3");
setTimeout(function() {
_audio.pause();
}, 4000);
奇怪的是,这似乎在Chrome中适用于我。 http://jsfiddle.net/9gLKM/ - 铬:版本22.0.1229.94米 – 2012-10-31 09:54:44