Skip to content

Instantly share code, notes, and snippets.

@alexcurylo
Created June 1, 2016 23:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcurylo/db743df00a6d27758b45c6537b26a800 to your computer and use it in GitHub Desktop.
Save alexcurylo/db743df00a6d27758b45c6537b26a800 to your computer and use it in GitHub Desktop.
class SomeViewController: UIViewController {
private typealias My = SomeViewController
private let videoPlayer: AVPlayer
private let videoPlayerLayer: AVPlayerLayer
override init(nibName: String?, bundle nibBundle: NSBundle?) {
(videoPlayer, videoPlayerLayer) = My.commonInit()
super.init(nibName: nibName, bundle: nibBundle)
}
required init?(coder decoder: NSCoder) {
(videoPlayer, videoPlayerLayer) = My.commonInit()
super.init(coder: decoder)
}
private static func commonInit() -> (AVPlayer, AVPlayerLayer) {
let player = AVPlayer(URL: NSURL(fileReferenceLiteral: "movie.mov"))
let layer = AVPlayerLayer(player: player)
return (player,layer)
}
}
Copy link

ghost commented Jan 15, 2019

Awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment