Merge pull request #772 from stonerl/re-enter-fullscreen-on-background-return

fixed fullscreen handling for backgrounding
This commit is contained in:
Arkadiusz Fal 2024-08-31 13:08:40 +02:00 committed by GitHub
commit e749307a0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,6 +56,7 @@ final class PlayerModel: ObservableObject {
@Published var presentingPlayer = false { didSet { handlePresentationChange() } } @Published var presentingPlayer = false { didSet { handlePresentationChange() } }
@Published var activeBackend = PlayerBackendType.mpv @Published var activeBackend = PlayerBackendType.mpv
@Published var forceBackendOnPlay: PlayerBackendType? @Published var forceBackendOnPlay: PlayerBackendType?
@Published var wasFullscreen = false
var avPlayerBackend = AVPlayerBackend() var avPlayerBackend = AVPlayerBackend()
var mpvBackend = MPVBackend() var mpvBackend = MPVBackend()
@ -979,6 +980,17 @@ final class PlayerModel: ObservableObject {
avPlayerBackend.bindPlayerToLayer() avPlayerBackend.bindPlayerToLayer()
} }
#if os(iOS)
if wasFullscreen {
wasFullscreen = false
DispatchQueue.main.async { [weak self] in
Delay.by(0.3) {
self?.enterFullScreen()
}
}
}
#endif
guard closePiPAndOpenPlayerOnEnteringForeground, playingInPictureInPicture else { guard closePiPAndOpenPlayerOnEnteringForeground, playingInPictureInPicture else {
return return
} }
@ -993,6 +1005,15 @@ final class PlayerModel: ObservableObject {
} else if !playingInPictureInPicture { } else if !playingInPictureInPicture {
avPlayerBackend.removePlayerFromLayer() avPlayerBackend.removePlayerFromLayer()
} }
#if os(iOS)
guard playingFullScreen else { return }
wasFullscreen = playingFullScreen
DispatchQueue.main.async { [weak self] in
Delay.by(0.3) {
self?.exitFullScreen(showControls: false)
}
}
#endif
} }
#endif #endif