Skip to content

Fix active and inactive tab playback and stalling for player - #939

Merged
Dananji merged 1 commit into
mainfrom
multi-tab-playback
Apr 21, 2026
Merged

Fix active and inactive tab playback and stalling for player#939
Dananji merged 1 commit into
mainfrom
multi-tab-playback

Conversation

@Dananji

@Dananji Dananji commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

Related issue: #714

Changes in this PR:

  • adds a visibilitychange listener in initializeEventHandlers (ramp-hooks.js) that pauses the player when the tab becomes inactive and resumes it when the tab becomes active again, preventing the playhead from advancing while the tab is inactive on iOS/iPadOS
  • on iOS, replaces Math.max(currentTimeRef.current, player.currentTime()) with currentTimeRef.current when setting the seek target in playerLoadedMetadata event, because iOS can advance player.currentTime() in the background before the visibilitychange pause takes effect, causing the player's seek event to jump-forward on next load
  • adds stalled event listener for iOS in to recover from stalling that happens in audio player. When VideoJS stalled event fires with readyState < 3, call player.load() and player.play() to un-stuck the player

@cjcolvar cjcolvar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job handling these iOS quirks! This looks good to me but there are some merge conflicts that need to be resolved.

@Dananji
Dananji force-pushed the multi-tab-playback branch from 7c0786f to 70210e6 Compare April 21, 2026 17:42
@Dananji
Dananji merged commit a919c32 into main Apr 21, 2026
4 checks passed
@Dananji
Dananji deleted the multi-tab-playback branch April 21, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants