Skip to content

Instantly share code, notes, and snippets.

@jebai0521
Created November 5, 2014 03:17
Show Gist options
  • Select an option

  • Save jebai0521/d368a31706d92f0bbbd0 to your computer and use it in GitHub Desktop.

Select an option

Save jebai0521/d368a31706d92f0bbbd0 to your computer and use it in GitHub Desktop.
方法1
1. 构造AVURLAsset
2. 请求key
3. 准备播放--检查请求结果
4. 准备播放--检查可否播放
5. 准备播放--预处理 AVPlayerItem
6. 准备播放--初始化 AVPlayerItem
7. 准备播放--预处理 AVPlayer
8. 准备播放--替换 AVPlayer 的 AVPlayerItem
方法2
1. 用nsurl 生成 AVPlayerItem
AVPlayerItem *playerItem = [AVPlayerItemplayerItemWithURL:url];
2. 添加播放状态监听
[playerItem addObserver:self
forKeyPath:@"status"
options:NSKeyValueObservingOptionNew
context:nil];
[playerItem addObserver:self
forKeyPath:@"playbackBufferEmpty"
options:NSKeyValueObservingOptionNew
context:nil];
[playerItem addObserver:self
forKeyPath:@"playbackLikelyToKeepUp"
options:NSKeyValueObservingOptionNew
context:nil];
[playerItem addObserver:self
forKeyPath:@"loadedTimeRanges"
options:NSKeyValueObservingOptionNew
context:nil];
相关的监控
相关的状态
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment