单击按钮后,我正在尝试添加子视图,然后将其置于前面并添加 AVPlayer 实例以播放广播流。音频正在播放,但 AVPlayer 不可见,我不确定如何使 AVPlayer 可见并将其放在子视图中。我一直在 Apple Library 中搜索示例和信息,但效果不佳。
下面是调用方法:
- (IBAction)radioButton:(id)sender {
radioButton.selected=TRUE;
twitterButton.selected=FALSE;
[self.view bringSubviewToFront:radioView];
radioView.hidden = FALSE;
NSURL *url = [NSURL URLWithString:@"http://streaming3.radiocat.net:80/"];
// You may find a test stream at <http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8>.
self.playerItem = [AVPlayerItem playerItemWithURL:url];
//[playerItem addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext];
self.player = [AVPlayer playerWithPlayerItem:playerItem];
[self.player play];
}
非常感谢