File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,27 @@ export function VideoOutput({
4343 }
4444 } , [ remoteStream ] ) ;
4545
46+ // Sync video element play/pause state with isPlaying prop
47+ useEffect ( ( ) => {
48+ const video = videoRef . current ;
49+ // playbackUrl indicates a cloud stream is playing
50+ if ( ! video || ! playbackUrl ) return ;
51+
52+ // Check if video state is out of sync with prop
53+ const shouldBePlaying = isPlaying ;
54+ const isActuallyPlaying = ! video . paused ;
55+
56+ if ( shouldBePlaying !== isActuallyPlaying ) {
57+ if ( shouldBePlaying ) {
58+ video . play ( ) . catch ( ( err ) => {
59+ console . error ( "[VideoOutput] Error playing video:" , err ) ;
60+ } ) ;
61+ } else {
62+ video . pause ( ) ;
63+ }
64+ }
65+ } , [ isPlaying , remoteStream , playbackUrl ] ) ;
66+
4667 // Listen for video playing event to notify parent
4768 useEffect ( ( ) => {
4869 const video = videoRef . current ;
@@ -67,6 +88,7 @@ export function VideoOutput({
6788
6889 const triggerPlayPause = useCallback ( ( ) => {
6990 // Allow play/pause when we have either a direct MediaStream or a cloud playback URL
91+ // Only call onPlayPauseToggle if this is a user action, not a prop sync
7092 if ( onPlayPauseToggle && ( remoteStream || playbackUrl ) ) {
7193 onPlayPauseToggle ( ) ;
7294
You can’t perform that action at this time.
0 commit comments