mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
28 lines
744 B
Swift
28 lines
744 B
Swift
import AVKit
|
|
import SwiftUI
|
|
|
|
final class PlayerViewController: NSViewController {
|
|
var playerModel: PlayerModel!
|
|
var playerView = AVPlayerView()
|
|
var pictureInPictureDelegate = PictureInPictureDelegate()
|
|
|
|
override func viewDidDisappear() {
|
|
if !playerModel.playingInPictureInPicture {
|
|
playerModel.pause()
|
|
}
|
|
super.viewDidDisappear()
|
|
}
|
|
|
|
override func loadView() {
|
|
playerView.player = playerModel.player
|
|
pictureInPictureDelegate.playerModel = playerModel
|
|
|
|
playerView.allowsPictureInPicturePlayback = true
|
|
playerView.showsFullScreenToggleButton = true
|
|
|
|
playerView.pictureInPictureDelegate = pictureInPictureDelegate
|
|
|
|
view = playerView
|
|
}
|
|
}
|