mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Fix pausing on dismissing player
This commit is contained in:
parent
e2e864e9da
commit
1d8efbda58
@ -21,7 +21,7 @@ final class PlayerModel: ObservableObject {
|
||||
var avPlayerViewController: AVPlayerViewController?
|
||||
#endif
|
||||
|
||||
@Published var presentingPlayer = false
|
||||
@Published var presentingPlayer = false { didSet { pauseOnPlayerDismiss() } }
|
||||
|
||||
@Published var stream: Stream?
|
||||
@Published var currentRate: Float = 1.0 { didSet { player.rate = currentRate } }
|
||||
@ -143,6 +143,14 @@ final class PlayerModel: ObservableObject {
|
||||
updateCurrentArtwork()
|
||||
}
|
||||
|
||||
private func pauseOnPlayerDismiss() {
|
||||
if !playingInPictureInPicture, !presentingPlayer {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
self.pause()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func insertPlayerItem(
|
||||
_ stream: Stream,
|
||||
for video: Video,
|
||||
|
@ -118,11 +118,6 @@ struct VideoPlayerView: View {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
.onDisappear {
|
||||
if !player.playingInPictureInPicture {
|
||||
player.pause()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func playerPlaceholder(geometry: GeometryProxy) -> some View {
|
||||
|
Loading…
Reference in New Issue
Block a user