Hi developers and experts, I need your good suggestions and help. I am working an application which has four different radio channels(buttons). I am using AVPlayer for live streaming. I would like to create an AVPlayer object in ViewDidLoad and just change the streaming url by using the four different buttons without having to re-create the AVPlayer object again and again. I googled but not find any solution. So your good suggestions and help would be appreciated. Thanks
- (IBAction)playBtn_clicked:(id)sender {
NSURL *streamURL = [NSURL URLWithString:urlString];
// I don't like this line, creating a new object again and again
_streamPlayer = [[AVPlayer alloc] initWithURL:streamURL];
if (_streamPlayer.rate == 1.0) {
[_streamPlayer pause];
} else {
[_streamPlayer play];
}
}