wavesurfer.js icon indicating copy to clipboard operation
wavesurfer.js copied to clipboard

Always start playing from 0 seconds, cannot play the specified position , when click wavesurfer

Open zhangzygit opened this issue 5 years ago • 7 comments

Wavesurfer.js version(s):

4.2.0

Browser and operating system version(s):

Chrome 86.0.4240.183 MacOS 10.15.7

Code needed to reproduce the issue:

the size of the audio files is 98m

Nov-09-2020 18-58-01

zhangzygit avatar Nov 09 '20 11:11 zhangzygit

Hi! Can you reproduce your problem with an example, maybe with codesandbox?

marizuccara avatar Nov 21 '20 12:11 marizuccara

if the backend parameter not 'WebAudio' it does not work

taskaijo avatar Nov 25 '20 18:11 taskaijo

@zhangzygit can you provide a link to the audio file in question for testing?

entonbiba avatar Jan 27 '21 05:01 entonbiba

backend: 'WebAudio'

HYiteam avatar Jul 07 '21 10:07 HYiteam

@thijstriemstra , have you eventually solved the issue? what the cause was?

andrewsml avatar Jan 28 '22 12:01 andrewsml

I believe the problem is how HTMLMediaElement behaves while setting its internal currentTime when the server serving audio files is not configured properly. Changing currentTime creates a byte range request for the server asking for a part of the audio file - and if this fails, the player sets currentTime to 0 by default.

I struggled for a while with this in one project since I had to serve the files with my own implementation. IIRC when I correctly handled the byte range requests Wavesurfer also began to work.

See this StackOverflow answer for reference.

Edit: Just noticed that it was katspaugh themselves that wrote the original stack overflow answer. 😄

samuliedvin avatar Jan 28 '22 13:01 samuliedvin

@samuliedvin , thanks for advice. solved that by applying Accept-Ranges header.

andrewsml avatar Jan 28 '22 15:01 andrewsml