1.流媒体指在Internet/Intranet中使用流式传输技术的连续时基媒体,如:音频、视频或多媒体文件。流式媒体在播放前并不下载整个文件,只将开始部分内容存入内存,流式媒体的数据流随时传送随时播放,只是在开始时有一些延迟。流媒体实现的关键技术就是流式传输。

2.这里的流媒体地址是指服务端那边已经调好格式的可以在ios上播放的视频流。

举例:http://www.jxvdy.com/file/upload/201309/18/18-10-03-19-3.mp4

3.iOS的影片播放 MediaPlayer 和 AVPlayer(framework)

在iOS开发商,如果要遇到播放影片,如开机动画,我們很習慣地會使用MediaPlayer來播放影片,因為很方便使用,所以就一直使用下去。但是隨著客戶的要求越來越嚴苛,尤其是過場動畫或互動效果上的表現。所以如果在一些動畫中還挾帶影片一起運算,那勢必機器會跑不動。所以在iOS 4之後,我們可以使用AVPlayer這個類別來進行更細微的操作。

備註:

  • MediaPlayer的影片是放在UIView 裡面,而AVPlayer是放在AVPlayerLayer裡面,AVPlayerLayer是CALayer 的子類別。
  • 使用MediaPlayer前,要記得加入MediaPlayer.framework及#import <MediaPlayer/MediaPlayer.h>
  • 使用AVPlayer前,要記得加入AVFoundation.frameworkk及#import <AVFoundation/AVFoundation.h>

請參考以下的範例:

使用MediaPlayer來播放影片

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"backspace" ofType:@"mov"];
NSURL *sourceMovieURL = [NSURL fileURLWithPath:filePath]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:sourceMovieURL];
moviePlayer.view.frame=CGRectMake(, , , );
moviePlayer.controlStyle=MPMovieControlStyleNone; // Play the movie!
[self.view addSubview:moviePlayer.view];

使用AVPlayer來播放影片:

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"backspace" ofType:@"mov"];
NSURL *sourceMovieURL = [NSURL fileURLWithPath:filePath]; AVAsset *movieAsset = [AVURLAsset URLAssetWithURL:sourceMovieURL options:nil];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:movieAsset];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = self.view.layer.bounds;
playerLayer.videoGravity = AVLayerVideoGravityResizeAspect; [self.view.layer addSublayer:playerLayer];
[player play];

最新文章

  1. SQL优化案例—— RowNumber分页
  2. Jenkins学习四:Jenkins 邮件配置
  3. Linux命令--删除软连接
  4. Nginx的第一个模块-HelloWorld
  5. select 触发事件
  6. cocoapods 更新
  7. 2015暑假多校联合---CRB and His Birthday(01背包)
  8. 时序列数据库武斗大会之TSDB名录 Part 2
  9. zookeeper 数据存储特点
  10. css3换行的三方式的对比(整理)
  11. JSP EL隐含对象
  12. 如何使用Python读取大文件
  13. 移动端click事件出现300ms延迟
  14. @staticmethod和@classmethod
  15. Python设计模式 - UML - 交互概述图(Interaction Overview Diagram)
  16. day 2 - 逻辑运算
  17. Ubuntu Eclipse C++运行问题:launch failed.Binary not found
  18. 田螺便利店—PyCharm安装第三方库
  19. MySQL聚合函数与数据分组
  20. BZOJ 3091: 城市旅行 lct 期望 splay

热门文章

  1. Flex布局如何让子类在超出边界时隐藏掉
  2. Wisdombud.CommonTool及其应用
  3. excel分组求和
  4. apache配置虚拟主机后,启动速度慢
  5. python报错ordinal not in range(128)
  6. Custom ReadOnlyProperty【PluraSight】
  7. Jupyter增加内核
  8. java中final的用法
  9. socat : Some useful commands
  10. SAE J1708 DS36277 MAX3444, DS75176B