Add PiP for iOS

This commit is contained in:
Arkadiusz Fal
2022-05-20 23:23:14 +02:00
parent 0c7f963378
commit 0d6f481470
9 changed files with 137 additions and 21 deletions

View File

@@ -173,6 +173,9 @@ struct PlayerControls: View {
HStack {
#if !os(tvOS)
fullscreenButton
#if os(iOS)
pipButton
#endif
rateButton
Spacer()
@@ -235,6 +238,26 @@ struct PlayerControls: View {
.init(get: { player.currentRate }, set: { rate in player.currentRate = rate })
}
private var pipButton: some View {
button("PiP", systemImage: "pip") {
if player.activeBackend == .mpv {
player.avPlayerBackend.switchToMPVOnPipClose = true
}
if player.activeBackend != PlayerBackendType.appleAVPlayer {
player.saveTime {
player.changeActiveBackend(from: .mpv, to: .appleAVPlayer)
}
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
print(player.pipController?.isPictureInPicturePossible ?? false ? "possible" : "NOT possible")
player.avPlayerBackend.enterPiPOnPlay = true
player.pipController?.startPictureInPicture()
}
}
}
var mediumButtonsBar: some View {
HStack {
#if !os(tvOS)