Last active
March 2, 2018 19:59
-
-
Save jasonyunjoonpark/20868fb981331a9bc4faa0cff8272c40 to your computer and use it in GitHub Desktop.
"Expected expression naming a method within '#selector(...)' LoginConroller.swift"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AVFoundation | |
class LoginController: UIViewController { | |
var Player: AVPlayer! | |
var PlayerLayer: AVPlayerLayer! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
//setup video background view | |
setupVideoBackgroundView() | |
} | |
@objc func handlePlayerVideoEnded(notification: NSNotification) { | |
Player.seek(to: kCMTimeZero) | |
} | |
fileprivate func setupVideoBackgroundView() { | |
let url = Bundle.main.url(forResource: "video", withExtension: "mp4") | |
Player = AVPlayer.init(url: url!) | |
PlayerLayer = AVPlayerLayer(player: Player) | |
PlayerLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill | |
PlayerLayer.frame = view.layer.frame | |
Player.actionAtItemEnd = AVPlayerActionAtItemEnd.none | |
Player.play() | |
view.layer.insertSublayer(PlayerLayer, at: 0) | |
NotificationCenter.default.addObserver(self, selector: #selector(handlePlayerVideoEnded(notification:)), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: Player.currentItem) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment