https://www.youtube.com/watch?v=L5j5kQEWN7o
위 링크 참조
var player:AVPlayer!
var playerLayer:AVPlayerLayer!
var user = User()
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.setNavigationBarHidden(true, animated: false)
let url = Bundle.main.url(forResource: "intro_vod", withExtension: "mp4")
player = AVPlayer(url: url!)
playerLayer = AVPlayerLayer(player: player)
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
playerLayer.frame = view.layer.frame
player.actionAtItemEnd = AVPlayerActionAtItemEnd.none
player.play()
view.layer.insertSublayer(playerLayer, at: 0)
NotificationCenter.default.addObserver(self, selector: #selector(playerItemReachEnd(notification:)), name: Notification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem)
}
func playerItemReachEnd(notification: Notification) {
player.seek(to: kCMTimeZero)
}
'프로그래밍 > iOS' 카테고리의 다른 글
[Swift3] S3 이미지 업로드 참고 자료 (0) | 2017.02.23 |
---|