Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
}
}
@ghost

This comment has been minimized.

Copy link

@ghost 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