點擊播放按鈕,開啟影片播放器,播放影片。
需要完成:
- Play Movie 按鈕
- AV Player View Controller
- 加入 AVKit.framework
// | |
// ViewController.swift | |
// PlayMovie | |
// | |
// Created by Edward Chiang on 16/11/2016. | |
// Copyright © 2016 TKU. All rights reserved. | |
// | |
import UIKit | |
import AVKit | |
import AVFoundation | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
// https://www.pond5.com/stock-video-footage/1/sport.html#2 | |
let destination : AVPlayerViewController = segue.destination as! AVPlayerViewController | |
destination.player = AVPlayer(url: URL.init(fileURLWithPath: Bundle.main.path(forResource: "goal-stadium-crowd-wild-fans-s", ofType: "mp4")! ) ) | |
} | |
} | |