Skip to content

Instantly share code, notes, and snippets.

@meyusufdemirci
Last active January 30, 2018 17:55
Show Gist options
  • Save meyusufdemirci/735f640653e2279b23aeb91d70f881de to your computer and use it in GitHub Desktop.
Save meyusufdemirci/735f640653e2279b23aeb91d70f881de to your computer and use it in GitHub Desktop.
import UIKit
import AVKit
class ViewController: UIViewController {
let playerController = AVPlayerViewController()
override func viewDidLoad() {
super.viewDidLoad()
// if you have a url of video
// let player = AVPlayer(url: URL(string: "video url")!)
let path = Bundle.main.path(forResource: "Mahmut Orhan - Game Of Thrones", ofType: "mp4")
// if you have a path of local video
let player = AVPlayer(url: URL(fileURLWithPath: path!))
playerController.player = player
playerController.view.frame = CGRect(x: 0, y: 200, width: UIScreen.main.bounds.width, height: 250)
self.view.addSubview(playerController.view)
playerController.player?.play()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment