Describe the Bug
AVPlayerEngine.swift hard-codes allowsExternalPlayback = true and usesExternalPlaybackWhileExternalScreenIsActive = true (Apple's default for the latter is false). For audio-only apps this causes a regression: when the user is screen-mirroring to an Apple TV and starts playback, AVPlayer enters external playback mode, the Apple TV shows a black native player, and mirroring stops. Apple Music and other audio apps keep mirroring in this scenario.
Steps To Reproduce
Enable screen mirroring to an Apple TV from an RNTP app and start playing audio.
Options
- Set both flags to
false to ensure screen mirroring always works. (FWIW, I have used a yarn patch to apply this fix for now.)
- Add an
iosAllowsExternalPlayback option or similar (default false, or at minimum leave usesExternalPlaybackWhileExternalScreenIsActive at Apple's default) so audio-only apps can opt out.
Workaround
--- a/ios/player/AVPlayerEngine.swift
+++ b/ios/player/AVPlayerEngine.swift
@@ -219,10 +219,10 @@ class AVPlayerEngine: NSObject, PlayerEngine, AVPlayerItemMetadataOutputPushDele
}
}
- avPlayer.allowsExternalPlayback = true
+ avPlayer.allowsExternalPlayback = false
#if !os(macOS)
// iOS-only API; the SPM test target builds PlayerCore for macOS.
- avPlayer.usesExternalPlaybackWhileExternalScreenIsActive = true
+ avPlayer.usesExternalPlaybackWhileExternalScreenIsActive = false
#endif
observeTimeControlStatus()
#if canImport(UIKit)
Describe the Bug
AVPlayerEngine.swifthard-codesallowsExternalPlayback = trueandusesExternalPlaybackWhileExternalScreenIsActive = true(Apple's default for the latter is false). For audio-only apps this causes a regression: when the user is screen-mirroring to an Apple TV and starts playback, AVPlayer enters external playback mode, the Apple TV shows a black native player, and mirroring stops. Apple Music and other audio apps keep mirroring in this scenario.Steps To Reproduce
Enable screen mirroring to an Apple TV from an RNTP app and start playing audio.
Options
falseto ensure screen mirroring always works. (FWIW, I have used a yarn patch to apply this fix for now.)iosAllowsExternalPlaybackoption or similar (default false, or at minimum leave usesExternalPlaybackWhileExternalScreenIsActive at Apple's default) so audio-only apps can opt out.Workaround