fix(VisionOS): do not access to isExternalPlaybackActive on VisionOS (#4109)
This commit is contained in:
parent
24c99f03b9
commit
0576eacfdd
@ -284,9 +284,18 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
|
|
||||||
// MARK: - App lifecycle handlers
|
// MARK: - App lifecycle handlers
|
||||||
|
|
||||||
|
func getIsExternalPlaybackActive() -> Bool {
|
||||||
|
#if os(visionOS)
|
||||||
|
let isExternalPlaybackActive = false
|
||||||
|
#else
|
||||||
|
let isExternalPlaybackActive = _player?.isExternalPlaybackActive ?? false
|
||||||
|
#endif
|
||||||
|
return isExternalPlaybackActive
|
||||||
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
func applicationWillResignActive(notification _: NSNotification!) {
|
func applicationWillResignActive(notification _: NSNotification!) {
|
||||||
let isExternalPlaybackActive = _player?.isExternalPlaybackActive ?? false
|
let isExternalPlaybackActive = getIsExternalPlaybackActive()
|
||||||
if _playInBackground || _playWhenInactive || !_isPlaying || isExternalPlaybackActive { return }
|
if _playInBackground || _playWhenInactive || !_isPlaying || isExternalPlaybackActive { return }
|
||||||
|
|
||||||
_player?.pause()
|
_player?.pause()
|
||||||
@ -295,7 +304,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
|
|
||||||
@objc
|
@objc
|
||||||
func applicationDidBecomeActive(notification _: NSNotification!) {
|
func applicationDidBecomeActive(notification _: NSNotification!) {
|
||||||
let isExternalPlaybackActive = _player?.isExternalPlaybackActive ?? false
|
let isExternalPlaybackActive = getIsExternalPlaybackActive()
|
||||||
if _playInBackground || _playWhenInactive || !_isPlaying || isExternalPlaybackActive { return }
|
if _playInBackground || _playWhenInactive || !_isPlaying || isExternalPlaybackActive { return }
|
||||||
|
|
||||||
// Resume the player or any other tasks that should continue when the app becomes active.
|
// Resume the player or any other tasks that should continue when the app becomes active.
|
||||||
@ -305,7 +314,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
|
|
||||||
@objc
|
@objc
|
||||||
func applicationDidEnterBackground(notification _: NSNotification!) {
|
func applicationDidEnterBackground(notification _: NSNotification!) {
|
||||||
let isExternalPlaybackActive = _player?.isExternalPlaybackActive ?? false
|
let isExternalPlaybackActive = getIsExternalPlaybackActive()
|
||||||
if !_playInBackground || isExternalPlaybackActive || isPipActive() { return }
|
if !_playInBackground || isExternalPlaybackActive || isPipActive() { return }
|
||||||
// Needed to play sound in background. See https://developer.apple.com/library/ios/qa/qa1668/_index.html
|
// Needed to play sound in background. See https://developer.apple.com/library/ios/qa/qa1668/_index.html
|
||||||
_playerLayer?.player = nil
|
_playerLayer?.player = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user