Skip to content

Instantly share code, notes, and snippets.

@edwardinubuntu
Last active November 22, 2016 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardinubuntu/08cef9f6162b040aacf91e13dadae2c6 to your computer and use it in GitHub Desktop.
Save edwardinubuntu/08cef9f6162b040aacf91e13dadae2c6 to your computer and use it in GitHub Desktop.
tibame.com iOS Swift 播放影片

播放影片

點擊播放按鈕,開啟影片播放器,播放影片。

需要完成:

  • 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")! ) )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment