mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Automatically dismiss player when playback finished on tvOS
This commit is contained in:
parent
8d5a191779
commit
c1d9e02475
@ -43,6 +43,9 @@ final class PlayerViewController: UIViewController {
|
|||||||
|
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
present(playerViewController, animated: false)
|
present(playerViewController, animated: false)
|
||||||
|
|
||||||
|
addItemDidPlayToEndTimeObserver()
|
||||||
|
|
||||||
#else
|
#else
|
||||||
embedViewController()
|
embedViewController()
|
||||||
#endif
|
#endif
|
||||||
@ -52,7 +55,22 @@ final class PlayerViewController: UIViewController {
|
|||||||
playerLoaded = true
|
playerLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !os(tvOS)
|
#if os(tvOS)
|
||||||
|
func addItemDidPlayToEndTimeObserver() {
|
||||||
|
NotificationCenter.default.addObserver(
|
||||||
|
self,
|
||||||
|
selector: #selector(itemDidPlayToEndTime),
|
||||||
|
name: NSNotification.Name.AVPlayerItemDidPlayToEndTime,
|
||||||
|
object: nil
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func itemDidPlayToEndTime() {
|
||||||
|
playerViewController.dismiss(animated: true) {
|
||||||
|
self.dismiss(animated: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
func embedViewController() {
|
func embedViewController() {
|
||||||
playerViewController.exitsFullScreenWhenPlaybackEnds = true
|
playerViewController.exitsFullScreenWhenPlaybackEnds = true
|
||||||
playerViewController.view.frame = view.bounds
|
playerViewController.view.frame = view.bounds
|
||||||
|
Loading…
Reference in New Issue
Block a user