1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-12 21:30:32 +05:30

fixed fullscreen handling for backgrounding

Currently when returning from background, the app is fullscreen but the video is in portrait mode.

Now when entering background we leave fullscreen and enter it again the the app is in foreground.

Signed-off-by: Toni Förster <toni.foerster@gmail.com>
This commit is contained in:
Toni Förster 2024-08-31 13:00:50 +02:00
parent a194738bb6
commit d76ec881be
No known key found for this signature in database
GPG Key ID: 292F3E5086C83FC7

View File

@ -56,6 +56,7 @@ final class PlayerModel: ObservableObject {
@Published var presentingPlayer = false { didSet { handlePresentationChange() } }
@Published var activeBackend = PlayerBackendType.mpv
@Published var forceBackendOnPlay: PlayerBackendType?
@Published var wasFullscreen = false
var avPlayerBackend = AVPlayerBackend()
var mpvBackend = MPVBackend()
@ -979,6 +980,17 @@ final class PlayerModel: ObservableObject {
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 {
return
}
@ -993,6 +1005,15 @@ final class PlayerModel: ObservableObject {
} else if !playingInPictureInPicture {
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