Add basic PiP support

This commit is contained in:
Arkadiusz Fal
2021-08-18 00:00:53 +02:00
parent 2dff68200d
commit 8d5a191779
6 changed files with 70 additions and 18 deletions

View File

@@ -23,6 +23,8 @@ final class PlayerState: ObservableObject {
let maxResolution: Stream.Resolution?
var timeObserver: Any?
var playingOutsideViewController = false
init(_ video: Video? = nil, maxResolution: Stream.Resolution? = nil) {
self.video = video
self.maxResolution = maxResolution
@@ -222,6 +224,11 @@ final class PlayerState: ObservableObject {
fileprivate func destroyPlayer() {
logger.critical("destroying player")
guard !playingOutsideViewController else {
logger.critical("cannot destroy, playing outside view controller")
return
}
player?.currentItem?.tracks.forEach { $0.assetTrack?.asset?.cancelLoading() }
player?.replaceCurrentItem(with: nil)