Open kjw3898 opened 2 years ago
Thanks for the detailed feedback. I was able to reproduce this without react as well, simply call player.src()
at some point, e.g:
player.src({src: 'media/hal.wav', type: 'audio/wav'});
and it triggers the waveReady
and playbackFinish
events twice. Calling player.src()
again results in those events being called three times so there I suspect there is something that doesn't clean up the event listeners properly..
Tested with video.js 7.17.0 with videojs-wavesurfer 3.8.0 and wavesurfer.js 5.2.0 on Firefox 94.0.2, macOS 12.0.1
Looks like it's related to this video.js issue? https://github.com/videojs/video.js/issues/4677
Description
I use this plugin on react, and it's nice project. thanks when I change the src the player, it looks good work.
this.player.src({src: '../media/hal.wav', type: 'audio/wav'});
but it fire event twice. if change the src once more, it fire event 3times
so I tried to find problem from my project, I found weird console message when init page ( first src load)
when change src
when change src again
if you use other event , that also duplicated . eg. playbackFinish
I tried to some workaround for this problem but not work
this.player.wavesurfer().load(item.path) // this code just change src of waveform. not audio(video.js src not changed)
Steps to reproduce
I can reproduce on react example in this repo with little change change the index.js ( /examples/react/index.js) to below code
and, open dev tool on web browser, click the button that title is click! then watch to console log
you'll see the result like this
Results
Expected
not duplicate event fire
Actual
duplicated event fire
Versions
Make sure to include the following versions:
videojs/wavesurfer
what version of video.js, videojs-wavesurfer and wavesurfer.js does this occur with? i checked this issue on VIDEOJS: Using video.js 7.15.4 with videojs-wavesurfer 3.8.0 and wavesurfer.js 5.2.0 <- example code version VIDEOJS: Using video.js 7.15.4 with videojs-wavesurfer 3.8.0, wavesurfer.js 5.2.0 and React 17.0.2 <- my project
Browsers OSes
I found this error on windows chrome, edge, and electron. other OS and browser not checked