1
我目前使用AVPlayerItem从URL播放实时流。我的代码是AVPlayerItem暂停实时流URL?
- (void)viewDidLoad
{
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://s4.voscast.com:8080/"]];
[playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:nil];
AVPlayer* player = [[AVPlayer playerWithPlayerItem:playerItem] retain];
[player play];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void) observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object
change:(NSDictionary*)change context:(void*)context {
if ([keyPath isEqualToString:@"timedMetadata"])
{
AVPlayerItem* playerItem = object;
for (AVMetadataItem* metadata in playerItem.timedMetadata)
{
NSLog(@"\nkey: %@\nkeySpace: %@\ncommonKey: %@\nvalue: %@", [metadata.key description], metadata.keySpace, metadata.commonKey, metadata.stringValue);
}
}
}
有没有什么办法,这是可以暂停,然后恢复正确的地方,在离开的,允许快进到重新站起来的生活吗?