视频

 // MARK: - 播放视频
     /*----- 播放视频 ------*/

     func moviePlayerPreloadFinish(notification:NSNotification)
     {
         println("播放完毕")
     }

     //声明一个媒体播放器
     var moviePlayer:MPMoviePlayerController?

     @IBAction func playMV()
     {
         let filePath:String? = NSBundle.mainBundle().pathForResource("namingRule", ofType: "mp4")

         //本地文件,使用fileURLWithPath来声明NSURL对象
         moviePlayer = MPMoviePlayerController(contentURL: NSURL(fileURLWithPath: filePath!))

         //如果播放网上视频,需要通过string方法来声明NSURL对象
 //        moviePlayer = MPMoviePlayerController(contentURL: NSURL(string: "视频网址"))

         //用MPMoviePlayerController做在线音乐播放
 //        moviePlayer = MPMoviePlayerController(contentURL: NSURL(string: "http://202.204.208.83/gangqin/download/music/02/03/02/Track08.mp3"))

         moviePlayer!.view.frame = self.view.frame;

         //设置播放器样式
         moviePlayer!.controlStyle = MPMovieControlStyle.Fullscreen
         self.view.addSubview(moviePlayer!.view)
         moviePlayer!.play()

         //需要使用 NSNotificationCenter 类,为电影播放器添加一个观察者(observer):

         var notificationCenter: Void = NSNotificationCenter.defaultCenter().addObserver(self, selector: "moviePlayerPreloadFinish:", name: MPMoviePlayerPlaybackDidFinishNotification, object: nil)
     }
     /*----- 播放视频 ------*/
     
 

ios开发——实用技术篇Swift篇&视频的更多相关文章

  1. ios开发——实用技术篇Swift篇&播放MP3

    播放MP3 // MARK: - 播放MP3 /*----- mp3 ------*/ //定时器- func updateTime() { //获取音频播放器播放的进度,单位秒 var cuTime ...

  2. ios开发——实用技术篇Swift篇&地址薄、短信、邮件

    //返回按钮事件 @IBAction func backButtonClick() { self.navigationController?.popViewControllerAnimated(tru ...

  3. ios开发——实用技术篇Swift篇&拍照

    拍照 // MARK: - 拍照 func fromPhotograph() { if UIImagePickerController.isSourceTypeAvailable(.Camera) { ...

  4. ios开发——实用技术篇Swift篇&照片选择

    照片选择 // MARK: - 选择照片 /*----- 选择照片 ------*/ @IBAction func addImageButtonClick() { let actionSheet = ...

  5. ios开发——实用技术篇Swift篇&系统声音

    系统声音 // MARK: - 系统声音 /*----- 系统声音 ------*/ @IBAction func systemSound() { //建立的SystemSoundID对象 var s ...

  6. ios开发——实用技术篇Swift篇&录音

    录音 // MARK: - 录音 /*----- 录音 ------*/ var recorder:AVAudioRecorder? //录音器 var player:AVAudioPlayer? / ...

  7. ios开发——实用技术篇Swift篇&加速计和陀螺仪

    加速计和陀螺仪 //返回按钮事件 @IBAction func backButtonClick() { self.navigationController?.popViewControllerAnim ...

  8. ios开发——实用技术篇Swift篇&多点触摸与手势识别

    多点触摸与手势识别 //点击事件 var atap = UITapGestureRecognizer(target: self, action: "tapDo:") self.vi ...

  9. ios开发——实用技术篇OC篇&iOS的主要框架

    iOS的主要框架         阅读目录 Foundation框架为所有的应用程序提供基本系统服务 UIKit框架提供创建基于触摸用户界面的类 Core Data框架管着理应用程序数据模型 Core ...

随机推荐

  1. [Everyday Mathematics]20150207

    求极限 $$\bex \lim_{x\to+\infty}\sex{\sqrt{x+\sqrt{x+\sqrt{x^\al}}}-\sqrt{x}},\quad\sex{0<\al<2}. ...

  2. [Java]读取文件方法大全

    1.按字节读取文件内容2.按字符读取文件内容3.按行读取文件内容 4.随机读取文件内容 , byteread);             }         } catch (IOException  ...

  3. HDU-1438 钥匙计数之一

    http://acm.hdu.edu.cn/showproblem.php?pid=1438                                钥匙计数之一 Time Limit: 200 ...

  4. <问题>Eclipse中Deploy应用到GAE的错误

    1.在Eclipse中部署App到Google App Engine(GAE),有时候会遇到这样的错误: java.lang.RuntimeException: Cannot get the Syst ...

  5. leetcode@ [354] Russian Doll Envelopes (Dynamic Programming)

    https://leetcode.com/problems/russian-doll-envelopes/ You have a number of envelopes with widths and ...

  6. 用一个例子学习CSS的伪类元素

    CSS伪类元素是一个非常酷的东西!首先我们理解一下它,:before :after 伪类元素,也就是虚假的元素.它可以插入在元素的前面或者后面,而在HTML文档结构中,它却是不存在的,因为Js是无法通 ...

  7. 【Linux常用工具】02. 创建启动定时任务工具cron

    一. cron 1. cron是一个守护程序,它提供定时器的功能,让用户在特定的时间得以执行默认的指令或程序.只要用户会编辑定时器的设置文件,就可以使用定时器的功能. 定时器文件格式: 2. cron ...

  8. contest7.20(暴力专练)

    此次练习的地址:  http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26732#overview 密码 acmore Problem A(P ...

  9. spring mvc 详细执行流程

    名词解释 DispatcherServlet:整个spring MVC的前端控制器,由它来接管来自客户端的请求. HandlerMapping:DispatcherServlet会通过它来处理客户端请 ...

  10. 山东理工大学ACM平台题答案关于C语言 1181 C语言实验——最小公倍数和最大公约数

    C语言实验——最小公倍数和最大公约数 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 从键盘输入两个正整数,求这两个正整数的最小公 ...