File tree Expand file tree Collapse file tree
react/src/components/layouts/plyr
vidstack/src/elements/define/layouts/plyr Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -752,9 +752,13 @@ function PlyrCaptions() {
752752
753753 React . useEffect ( ( ) => {
754754 if ( ! $track ) return ;
755- return listenEvent ( $track , 'cue-change' , ( ) => {
756- setActiveCue ( $track ?. activeCues [ 0 ] ) ;
757- } ) ;
755+
756+ function onCueChange ( ) {
757+ setActiveCue ( $track ? $track . activeCues [ 0 ] : null ) ;
758+ }
759+
760+ onCueChange ( ) ;
761+ return listenEvent ( $track , 'cue-change' , onCueChange ) ;
758762 } , [ $track ] ) ;
759763
760764 return (
Original file line number Diff line number Diff line change @@ -507,11 +507,14 @@ function Captions() {
507507
508508 effect ( ( ) => {
509509 const track = media . $state . textTrack ( ) ;
510- return track
511- ? listenEvent ( track , 'cue-change' , ( ) => {
512- activeCue . set ( track ?. activeCues [ 0 ] ) ;
513- } )
514- : null ;
510+ if ( ! track ) return ;
511+
512+ function onCueChange ( ) {
513+ activeCue . set ( track ?. activeCues [ 0 ] ) ;
514+ }
515+
516+ onCueChange ( ) ;
517+ return listenEvent ( track , 'cue-change' , onCueChange ) ;
515518 } ) ;
516519
517520 return html `
You can’t perform that action at this time.
0 commit comments