@@ -455,19 +455,8 @@ class VideoPlayer extends Utils.mixin(Eventable) {
455455 // Update mobile touch state based on current playback
456456 this . _updateMobileTouchState ( ) ;
457457
458- // Remove the overlay after timeout
459- this . videojs . clearTimeout ( this . _mobileTouchTimeout ) ;
460- this . _mobileTouchTimeout = this . videojs . setTimeout ( ( ) => {
461- // First remove the visibility class to start fade-out
462- this . videojs . removeClass ( 'cld-mobile-touch-active' ) ;
463-
464- // Wait for CSS transition to complete before removing pause icon class
465- setTimeout ( ( ) => {
466- this . videojs . removeClass ( 'cld-mobile-touch-playing' ) ;
467- this . _removeMobileBigPlayButtonHandler ( ) ;
468- this . _mobileInteractionActive = false ; // End mobile interaction session
469- } , 250 ) ; // Wait slightly longer than the 0.2s CSS transition
470- } , 3000 ) ;
458+ // Set up listener for VideoJS user activity events to sync with controls
459+ this . _setupMobileInactivityHandler ( ) ;
471460 }
472461 } ;
473462
@@ -492,8 +481,14 @@ class VideoPlayer extends Utils.mixin(Eventable) {
492481 // Clean up on dispose
493482 this . videojs . on ( 'dispose' , ( ) => {
494483 playerElement . removeEventListener ( 'touchend' , handleMobileTouch ) ;
495- this . videojs . clearTimeout ( this . _mobileTouchTimeout ) ;
496484 this . _removeMobileBigPlayButtonHandler ( ) ;
485+
486+ // Clean up inactivity handler
487+ if ( this . _mobileInactivityHandler ) {
488+ this . videojs . off ( 'userinactive' , this . _mobileInactivityHandler ) ;
489+ this . _mobileInactivityHandler = null ;
490+ }
491+
497492 this . _mobileTouchHandlerSetup = false ;
498493 this . _mobileInteractionActive = false ;
499494 } ) ;
@@ -509,23 +504,48 @@ class VideoPlayer extends Utils.mixin(Eventable) {
509504 }
510505 }
511506
507+ _setupMobileInactivityHandler ( ) {
508+ // Remove any existing inactivity handler
509+ if ( this . _mobileInactivityHandler ) {
510+ this . videojs . off ( 'userinactive' , this . _mobileInactivityHandler ) ;
511+ }
512+
513+ // Create handler that syncs with VideoJS control bar timing
514+ this . _mobileInactivityHandler = ( ) => {
515+ // Start fade-out when VideoJS controls fade out
516+ this . videojs . removeClass ( 'cld-mobile-touch-active' ) ;
517+
518+ // Wait for CSS transition to complete before cleanup
519+ setTimeout ( ( ) => {
520+ this . videojs . removeClass ( 'cld-mobile-touch-playing' ) ;
521+ this . _removeMobileBigPlayButtonHandler ( ) ;
522+ this . _mobileInteractionActive = false ; // End mobile interaction session
523+
524+ // Remove the inactivity handler since this touch session is done
525+ if ( this . _mobileInactivityHandler ) {
526+ this . videojs . off ( 'userinactive' , this . _mobileInactivityHandler ) ;
527+ this . _mobileInactivityHandler = null ;
528+ }
529+ } , 250 ) ; // Wait slightly longer than the 0.2s CSS transition
530+ } ;
531+
532+ // Listen for VideoJS user inactivity (when controls fade out)
533+ this . videojs . one ( 'userinactive' , this . _mobileInactivityHandler ) ;
534+ }
535+
512536 _updateMobileTouchState ( ) {
513537 const isPlaying = ! this . videojs . paused ( ) ;
514538
515539 if ( isPlaying ) {
516540 this . videojs . addClass ( 'cld-mobile-touch-playing' ) ;
517- this . _setupMobileBigPlayButtonHandler ( true ) ;
541+ this . _setupMobileBigPlayButtonHandler ( ) ;
518542 } else {
519543 this . videojs . removeClass ( 'cld-mobile-touch-playing' ) ;
520544 this . _removeMobileBigPlayButtonHandler ( ) ;
521545 }
522546 }
523547
524- _setupMobileBigPlayButtonHandler ( isPlaying ) {
525- if ( ! isPlaying ) {
526- return ; // Use default play behavior when paused
527- }
528-
548+ _setupMobileBigPlayButtonHandler ( ) {
529549 // Remove any existing handler first
530550 this . _removeMobileBigPlayButtonHandler ( ) ;
531551
0 commit comments