Fix switching to AVPlayer in fullscreen

This commit is contained in:
Arkadiusz Fal 2023-06-07 21:39:03 +02:00
parent f3a8a0977c
commit 8d11a92f97
3 changed files with 26 additions and 1 deletions

View File

@ -353,9 +353,11 @@ final class AVPlayerBackend: PlayerBackend {
} }
self.model.lastSkipped = segment self.model.lastSkipped = segment
self.model.handleOnPlayStream(stream)
self.model.play() self.model.play()
} }
} else { } else {
self.model.handleOnPlayStream(stream)
self.model.play() self.model.play()
} }
} }
@ -486,7 +488,9 @@ final class AVPlayerBackend: PlayerBackend {
if self.model.activeBackend == .appleAVPlayer, if self.model.activeBackend == .appleAVPlayer,
self.isAutoplaying(playerItem) self.isAutoplaying(playerItem)
{ {
if model.aspectRatio != aspectRatio {
self.model.updateAspectRatio() self.model.updateAspectRatio()
}
if self.startPictureInPictureOnPlay, if self.startPictureInPictureOnPlay,
let controller = self.model.pipController, let controller = self.model.pipController,
@ -708,6 +712,17 @@ final class AVPlayerBackend: PlayerBackend {
} else { } else {
stopMusicMode() stopMusicMode()
} }
#if os(iOS)
ControlOverlaysModel.shared.hide()
model.navigation.presentingPlaybackSettings = false
if model.playingFullScreen {
model.onPlayStream.append { _ in
self.controller.enterFullScreen(animated: true)
}
}
#endif
} }
var isStartingPiP: Bool { var isStartingPiP: Bool {

View File

@ -267,9 +267,11 @@ final class MPVBackend: PlayerBackend {
self.model.lastSkipped = segment self.model.lastSkipped = segment
self.play() self.play()
self.model.handleOnPlayStream(stream)
} }
} else { } else {
self.play() self.play()
self.model.handleOnPlayStream(stream)
} }
} }
} }

View File

@ -182,6 +182,7 @@ final class PlayerModel: ObservableObject {
private var currentArtwork: MPMediaItemArtwork? private var currentArtwork: MPMediaItemArtwork?
var onPresentPlayer = [() -> Void]() var onPresentPlayer = [() -> Void]()
var onPlayStream = [(Stream) -> Void]()
private var remoteCommandCenterConfigured = false private var remoteCommandCenterConfigured = false
init() { init() {
@ -1093,4 +1094,11 @@ final class PlayerModel: ObservableObject {
guard let videoWidth = backend?.videoWidth, let videoHeight = backend?.videoHeight else { return "unknown" } guard let videoWidth = backend?.videoWidth, let videoHeight = backend?.videoHeight else { return "unknown" }
return "\(String(format: "%.2f", videoWidth))\u{d7}\(String(format: "%.2f", videoHeight))" return "\(String(format: "%.2f", videoWidth))\u{d7}\(String(format: "%.2f", videoHeight))"
} }
func handleOnPlayStream(_ stream: Stream) {
backend.setRate(currentRate)
onPlayStream.forEach { $0(stream) }
onPlayStream.removeAll()
}
} }