Setting playbackRate on audio element connected to web audio api

后端 未结 2 2059
栀梦
栀梦 2021-01-13 01:00

I\'ve been experimenting with connecting an audio element to the web audio api using createMediaElementSource and got it to work but one thing I need to do is change the pla

2条回答
  •  不要未来只要你来
    2021-01-13 01:40

    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.

提交回复
热议问题