Setting playbackRate on audio element connected to web audio api

孤者浪人 提交于 2019-12-01 18:15:10

Which browser are you using to test this? It seems this is not yet implemented in Firefox, but should be working on Chrome.

Mozilla bug for implementing playbackRate: https://bugzilla.mozilla.org/show_bug.cgi?id=495040

You have to set the playback rate after the audio has started playing. The only portable way I have found to make this work, is by waiting until you get a timeupdate event with valid currentTime:

_audio.addEventListener('timeupdate', function(){
    _if(!isNaN(audio.currentTime)) {
        _audio.playbackRate = 0.6;
    }
});

Note that playback rate isn't currently supported on android and that Chrome (on desktop) doesn't support playback rates lower than 0.5.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!