1.首先导入 MediaPlayer
import MediaPlayer
2.播放事件
class ViewController:UIViewController{
var pc:MPMoviePlayerViewController!
@IBAction func playVideoBtnClicked(sender:AnyObject){
//播放资源
pc=MPMoviePlayerViewController(contentURL:NSBundle.mainBundle().URLForResource("video",
withExtension:"mp4"))
//播放
presentViewController(pc,animated:true,completion:nil)
}
}
时间: 2024-10-13 23:19:43