Skip to content

fix(RCTVideo.swift): add audiovisualBackgroundPlaybackPolicy when pla…#4570

Merged
KrzysztofMoch merged 1 commit intoTheWidlarzGroup:masterfrom
Dawqss:fix/ios_play_in_background_mode
Jul 13, 2025
Merged

fix(RCTVideo.swift): add audiovisualBackgroundPlaybackPolicy when pla…#4570
KrzysztofMoch merged 1 commit intoTheWidlarzGroup:masterfrom
Dawqss:fix/ios_play_in_background_mode

Conversation

@Dawqss
Copy link

@Dawqss Dawqss commented Jun 12, 2025

Summary of Changes

  • Fixed iOS background playback behavior:
    Added logic to set audiovisualBackgroundPlaybackPolicy on the player instance to ensure video continues playing when the app goes into the background.
if (_playInBackground) {
    _player!.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
} else {
    _player!.audiovisualBackgroundPlaybackPolicy = .automatic
}
  • Without this, iOS would consistently pause video playback when the app was backgrounded, even if background playback was expected.

How to test:

Just play any video with react-native-video player and go to background, video should pause

Motivation

Video stopped playing in background mode even though playInBackground was set to true.

Copy link
Contributor

@KrzysztofMoch KrzysztofMoch left a comment

Choose a reason for hiding this comment

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

Thank you for PR!
Our current min version of iOS is 13.0, but this property is 15.0+ (from what I can see in docs). Can you add version availability check? Thanks!

@Dawqss Dawqss force-pushed the fix/ios_play_in_background_mode branch from d41ef2e to d2be7b7 Compare July 10, 2025 12:04
@Dawqss Dawqss force-pushed the fix/ios_play_in_background_mode branch from d2be7b7 to 51b4d65 Compare July 10, 2025 12:06
Copy link
Contributor

@KrzysztofMoch KrzysztofMoch left a comment

Choose a reason for hiding this comment

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

Thanks!

@KrzysztofMoch KrzysztofMoch merged commit bf81038 into TheWidlarzGroup:master Jul 13, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants