feat(ios): set proper audiovisualBackgroundPlaybackPolicy for background mode (#16)

This commit is contained in:
Krzysztof Moch
2025-06-18 08:45:12 +02:00
committed by GitHub
parent 235bc3bea3
commit cf34670c0a
4 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -78,7 +78,7 @@
},
"packages/react-native-video": {
"name": "react-native-video",
"version": "7.0.0-dev.9",
"version": "7.0.0-dev.10",
"devDependencies": {
"@expo/config-plugins": "^10.0.2",
"@react-native/eslint-config": "^0.77.0",
+2 -2
View File
@@ -1565,7 +1565,7 @@ PODS:
- React-logger (= 0.77.2)
- React-perflogger (= 0.77.2)
- React-utils (= 0.77.2)
- ReactNativeVideo (7.0.0-dev.9):
- ReactNativeVideo (7.0.0-dev.10):
- DoubleConversion
- glog
- hermes-engine
@@ -1876,7 +1876,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: f334cebc0beed0a72490492e978007082c03d533
ReactCodegen: 474fbb3e4bb0f1ee6c255d1955db76e13d509269
ReactCommon: 7763e59534d58e15f8f22121cdfe319040e08888
ReactNativeVideo: 04b4d110e8d2bac7cbe51be0dd4932a72d2f1404
ReactNativeVideo: ea986c62571fe0cb6d953215419aa4ba6555ff2f
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 31a098f74c16780569aebd614a0f37a907de0189
@@ -224,6 +224,17 @@ class VideoManager {
)
}
// Set up background playback policy if needed
if backgroundPlayback {
players.allObjects.forEach { player in
if player.playInBackground {
player.player?.audiovisualBackgroundPlaybackPolicy = .continuesIfPossible
} else {
player.player?.audiovisualBackgroundPlaybackPolicy = .pauses
}
}
}
return .playback
}
@@ -157,7 +157,11 @@ class HybridVideoPlayer: HybridVideoPlayerSpec {
}
}
var playInBackground: Bool = false
var playInBackground: Bool = false {
didSet {
VideoManager.shared.requestAudioSessionUpdate()
}
}
var playWhenInactive: Bool = false