AVPlayer background music mode

This commit is contained in:
Arkadiusz Fal
2022-08-20 22:31:03 +02:00
parent b5f8a0fba2
commit 48e616b301
6 changed files with 129 additions and 41 deletions

View File

@@ -90,7 +90,7 @@ struct VideoPlayerView: View {
Spacer()
#endif
}
#if os(macOS)
#if !os(tvOS)
.frame(width: player.playerSize.width)
#endif
@@ -103,6 +103,11 @@ struct VideoPlayerView: View {
#endif
}
}
.onAppear {
if player.musicMode {
player.backend.startControlsUpdates()
}
}
}
var videoPlayer: some View {
@@ -435,10 +440,14 @@ struct VideoPlayerView: View {
guard player.presentingPlayer,
!playerControls.presentingControlsOverlay else { return }
if playerControls.presentingControls {
if playerControls.presentingControls, !player.musicMode {
playerControls.presentingControls = false
}
if player.musicMode {
player.backend.stopControlsUpdates()
}
let drag = value.translation.height
guard drag > 0 else { return }
@@ -479,6 +488,10 @@ struct VideoPlayerView: View {
}
player.backend.setNeedsDrawing(true)
player.show()
if player.musicMode {
player.backend.startControlsUpdates()
}
}
}