cookpete / react-player

A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion
https://cookpete.github.io/react-player
MIT License
8.89k stars 1.12k forks source link

dynamic url pause intermittently #1767

Closed jooyoni closed 3 weeks ago

jooyoni commented 1 month ago

I am implementing a feature where users can watch videos in their selected language. I am using three react-player components to simultaneously play video, background sound, and voice (played in the language chosen by the user). However, I encounter an issue where intermittently the audio playback stops when changing the language while continuously updating the progress bar.

The problem seems to occur during the process of changing the language, where a new URL is set, and the seekTo method is used to move to the previous playback time. Despite attempting to address this by changing the URL upon language switch and using onReady to execute the seekTo method once prepared, the issue persists, albeit with some slight improvement.

I've verified that the 'playing' state remains true throughout this process. To summarize, the URL continuously changes, and upon each change, the seekTo method adjusts the playback time accordingly. However, during this process, the player intermittently stops. Do you have any insights into what might be causing this issue?

Below is the code for the player that changes according to the language.

`<ReactPlayer url={voice[subtitleLang]} ref={audioPlayerRef2} onReady={() => { setAudioReady2(true); }} playing={ play && (onAudioBuffer2 || (!onBuffer && !onAudioBuffer)) } onBuffer={() => { setOnAudioBuffer2(true); }} onBufferEnd={() => { setOnAudioBuffer2(false); }} controls loop={false} muted={!useSound}

`