diff --git a/bun.lock b/bun.lock index 52657887..adf7fcaf 100644 --- a/bun.lock +++ b/bun.lock @@ -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", diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 63f62f86..680e213f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -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 diff --git a/packages/react-native-video/ios/core/VideoManager.swift b/packages/react-native-video/ios/core/VideoManager.swift index 27b300c8..195facff 100644 --- a/packages/react-native-video/ios/core/VideoManager.swift +++ b/packages/react-native-video/ios/core/VideoManager.swift @@ -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 } diff --git a/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift b/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift index 343f9c2f..822d6c4a 100644 --- a/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift +++ b/packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift @@ -157,7 +157,11 @@ class HybridVideoPlayer: HybridVideoPlayerSpec { } } - var playInBackground: Bool = false + var playInBackground: Bool = false { + didSet { + VideoManager.shared.requestAudioSessionUpdate() + } + } var playWhenInactive: Bool = false