Fullscreen handling changes

This commit is contained in:
Arkadiusz Fal
2022-04-03 14:23:42 +02:00
parent 76df80578d
commit 9edcf66557
6 changed files with 66 additions and 53 deletions

View File

@@ -88,26 +88,6 @@ final class PlayerControlsModel: ObservableObject {
}
}
func toggleFullscreen(_ value: Bool) {
withAnimation(Animation.easeOut) {
resetTimer()
withAnimation(PlayerControls.animation) {
playingFullscreen = !value
}
#if os(iOS)
if playingFullscreen {
guard !(UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isLandscape ?? true) else {
return
}
Orientation.lockOrientation(.landscape, andRotateTo: .landscapeRight)
} else {
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait)
}
#endif
}
}
func reset() {
currentTime = .zero
duration = .zero

View File

@@ -382,8 +382,8 @@ final class PlayerModel: ObservableObject {
return "\(formatter.string(from: NSNumber(value: rate))!)×"
}
func closeCurrentItem() {
prepareCurrentItemForHistory()
func closeCurrentItem(finished: Bool = false) {
prepareCurrentItemForHistory(finished: finished)
currentItem = nil
backend.closeItem()
@@ -498,4 +498,25 @@ final class PlayerModel: ObservableObject {
currentArtwork = MPMediaItemArtwork(boundsSize: image!.size) { _ in image! }
}
func toggleFullscreen(_ isFullScreen: Bool) {
controls.resetTimer()
#if os(macOS)
Windows.player.toggleFullScreen()
#endif
controls.playingFullscreen = !isFullScreen
#if os(iOS)
if controls.playingFullscreen {
guard !(UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isLandscape ?? true) else {
return
}
Orientation.lockOrientation(.landscape, andRotateTo: .landscapeRight)
} else {
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: .portrait)
}
#endif
}
}