标签:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import UIKit import MediaPlayer class ViewController : UIViewController { var moviePlayer: MPMoviePlayerController ? override func viewDidLoad() { super .viewDidLoad() //定义一个视频文件路径 let filePath = NSBundle .mainBundle().pathForResource( "sample130" , ofType: "mp4" ) //定义一个视频播放器,通过本地文件路径初始化 moviePlayer = MPMoviePlayerController (contentURL: NSURL (fileURLWithPath: filePath!)) //设置播放器样式 - 全屏 moviePlayer!.controlStyle = MPMovieControlStyle . Fullscreen //设置大小和位置 moviePlayer?.view.frame = self .view.frame //添加到界面上 self .view.addSubview(moviePlayer!.view) //开始播放 moviePlayer?.play() } override func didReceiveMemoryWarning() { super .didReceiveMemoryWarning() } } |
1
|
|
Swift - 使用Media Player播放本地视频,在线视频
标签:
原文地址:http://www.cnblogs.com/Free-Thinker/p/4843418.html