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