Improve PiP

Fix #186
Fix #196
This commit is contained in:
Arkadiusz Fal
2022-08-26 22:17:21 +02:00
parent 99881ccc23
commit 60f38a80aa
13 changed files with 173 additions and 104 deletions

View File

@@ -95,7 +95,7 @@ extension AppleAVPlayerViewController: AVPlayerViewControllerDelegate {
}
func playerViewControllerWillBeginDismissalTransition(_: AVPlayerViewController) {
if Defaults[.pauseOnHidingPlayer] {
if Defaults[.pauseOnHidingPlayer], !playerModel.playingInPictureInPicture {
playerModel.pause()
}
dismiss(animated: false)
@@ -121,15 +121,12 @@ extension AppleAVPlayerViewController: AVPlayerViewControllerDelegate {
self.playerModel.show()
self.playerModel.setNeedsDrawing(true)
#if os(tvOS)
if self.playerModel.playingInPictureInPicture {
self.present(self.playerView, animated: false) {
completionHandler(true)
}
if self.playerModel.playingInPictureInPicture {
self.present(self.playerView, animated: false) {
completionHandler(true)
}
#else
completionHandler(true)
#endif
}
completionHandler(true)
}
}

View File

@@ -277,9 +277,11 @@ struct PlayerControls: View {
}
private var pipButton: some View {
button("PiP", systemImage: "pip") {
model.startPiP()
let image = player.transitioningToPiP ? "pip.fill" : player.pipController?.isPictureInPictureActive ?? false ? "pip.exit" : "pip.enter"
return button("PiP", systemImage: image) {
(player.pipController?.isPictureInPictureActive ?? false) ? player.closePiP() : player.startPiP()
}
.disabled(!player.pipPossible)
}
#if os(iOS)