LoginSignup
7
11

More than 5 years have passed since last update.

Swift: 動画再生

Posted at

Frameworks追加

スクリーンショット 2017-03-01 23.30.53.png

ソース追加

qiita.rb
import UIKit
import AVFoundation
import AVKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let path = Bundle.main.path(forResource: "movie.mp4", ofType: nil)

        let player = AVPlayer(url: URL(fileURLWithPath:path!))
        let playerController = AVPlayerViewController()

        playerController.player = player
        self.addChildViewController(playerController)
        self.view.addSubview(playerController.view)
        playerController.view.frame = self.view.frame
        player.play()
    }

}


7
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
11