I’m trying to add a subview once button is clicked, then bring it to front and add an AVPlayer instance to play radio streaming. Audio is playing, but AVPlayer is not visible, I’m not sure how to make AVPlayer visible an place it in the subview. I’ve been searching for an example and information in Apple Library, but it’s poor about it.
Here is the call method:
- (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];
}
Many thanks
AVPlayer does not have its own UI, you have to create it yourself from UIKit classes and connect the relevant IBAction messages from their operation to methods that control the AVPlayer instance.