Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

update Picture-in-Picture for the App #682

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Emitron/Emitron/Support Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
21 changes: 20 additions & 1 deletion Emitron/Emitron/UI/Video/FullScreenVideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ extension FullScreenVideoPlayer: UIViewControllerRepresentable {
private let model: VideoPlaybackViewModel
private let handleDismissal: () -> Void
private var playerIsPresented = false

private var isDuringPip = false

@available(*, unavailable) required init?(coder: NSCoder) {
preconditionFailure("init(coder:) has not been implemented")
}
Expand Down Expand Up @@ -124,6 +125,24 @@ extension FullScreenVideoPlayer.Presenter: AVPlayerViewControllerDelegate {
willEndFullScreenPresentationWithAnimationCoordinator _: UIViewControllerTransitionCoordinator
) {
model.stop()
print(isDuringPip)
if !isDuringPip {
handleDismissal()
}
}

func playerViewController(_ playerViewController: AVPlayerViewController, restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void) {
present(playerViewController, animated: false) {
completionHandler(true)
}
}

func playerViewControllerWillStartPictureInPicture(_ playerViewController: AVPlayerViewController) {
isDuringPip = true
}

func playerViewControllerWillStopPictureInPicture(_ playerViewController: AVPlayerViewController) {
isDuringPip = false
handleDismissal()
}
}