HTML5 audio starts from the wrong position in Firefox

后端 未结 5 993
栀梦
栀梦 2021-01-04 12:09

I\'m trying to play an mp3 file and I want to jump to specific location in the file. In Chrome 33 on Windows, the file jumps the correct position (as compared with VLC play

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-04 12:30

    I just tried your code with another audio url here, it seemed to work and i did not experience a delay of any sort in Firefox( v29) which i did previously.

    
    

    I guess to jump around an audio file, your server must be configured properly.

    The client sends byte range requests to seek and play certain regions of a file, so the server must response adequately:

    In order to support seeking and playing back regions of the media that aren't yet downloaded, Gecko uses HTTP 1.1 byte-range requests to retrieve the media from the seek target position. In addition, if you don't serve X-Content-Duration headers, Gecko uses byte-range requests to seek to the end of the media (assuming you serve the Content-Length header) in order to determine the duration of the media.

    Hope this helps.. You could also try looking into Web Audio API for sound-effect-like playback which gives you some guarantees about the playback delays.

提交回复
热议问题