Fix Video Player Behavior on Screen Lock for iOS and Android#92
Merged
kdroidFilter merged 9 commits intomasterfrom Jul 30, 2025
Merged
Conversation
Introduced the `initializeplayerState` parameter to control whether videos start playing automatically or remain paused after opening. Updated methods, documentation, and UI components across platforms to support and reflect this behavior. Enhanced customization and user control over playback initialization.
Introduced the `initializeplayerState` parameter to control whether videos start playing automatically or remain paused after opening. Updated methods, documentation, and UI components across platforms to support and reflect this behavior. Enhanced customization and user control over playback initialization.
Introduced the ability to start video playback in a paused state by adding a `startPlayback` parameter to media initialization. Enhanced frame caching and state management to ensure smooth handling of initial paused states, preventing unwanted playback and ensuring proper UI loading behavior.
Ensure proper initialization and cleanup by updating loading state on initialization, marking user pause explicitly, and resetting the current frame during media release.
…on Android by updating `_hasMedia` and adding a pause action when playback isn't started automatically.
Centralized resource cleanup by introducing `cleanupCurrentPlayer` for better maintainability and consistency. Updated observer management to prevent redundant updates and improved playback state transitions. Enhanced periodic position update handling by associating observers with specific player instances.
…emove unused imports in `VideoPlayerSurface` for cleanup.
Implemented screen lock detection on Android and app lifecycle observers on iOS to manage playback behavior during screen locks or app backgrounding. Enhanced state handling to pause/resume playback automatically based on device state changes, ensuring consistent playback experience across platforms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses inconsistent behavior when locking the screen during video playback across iOS and Android platforms. Previously, on Android, videos would continue playing when the screen was locked, while on iOS, videos would pause but the
isPlayingstate would incorrectly remaintrue.Changes Made
iOS Implementation
UIApplicationDidEnterBackgroundNotification(screen lock)UIApplicationWillEnterForegroundNotification(screen unlock)isPlayingstate to match the actual player stateisPlayingstateAndroid Implementation
BroadcastReceiverto listen for screen events:ACTION_SCREEN_OFF(screen lock)ACTION_SCREEN_ON(screen unlock)Benefits
isPlayingstate that correctly reflects the actual playback stateThis PR resolves the issue where
playerState.isPlayingwould returntrueon iOS even when the video was actually paused after screen lock. #75