我正在尝试为 iPhone 开发一个应用程序。这是我的第一个 iPhone 应用程序,所以请多多包涵。我目前很容易将 mp3 音频从 Icecast 流式传输到 android。但是我不知道如何对 iPhone 做同样的事情。我已经阅读了很多关于 HLS 的文章,但是我可以从 Icecast 中做到这一点吗?或者还有其他选择吗?
问问题
1502 次
1 回答
1
AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:urlString]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[songPlayer currentItem]];
[player addObserver:self forKeyPath:@"status" options:0 context:nil];
[player play];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (object == player && [keyPath isEqualToString:@"status"]) {
if (songPlayer.status == AVPlayerStatusFailed) {
NSLog(@"AVPlayer Failed");
} else if (songPlayer.status == AVPlayerStatusReadyToPlay) {
NSLog(@"AVPlayerStatusReadyToPlay");
} else if (songPlayer.status == AVPlayerItemStatusUnknown) {
NSLog(@"AVPlayer Unknown");
}
}
}
于 2013-11-27T15:51:01.680 回答