I want to play a music file using URL Link in the iPhone. But when I use the below code I am getting error I am not getting where I am going wrong. Can anyone Correct me?
This should work:
NSURL *url = [NSURL URLWithString:@"<#Live stream URL#>];
// You may find a test stream at .
self.playerItem = [AVPlayerItem playerItemWithURL:url];
//(optional) [playerItem addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext];
self.player = [AVPlayer playerWithPlayerItem:playerItem];
self.player = [AVPlayer playerWithURL:<#Live stream URL#>];
//(optional) [player addObserver:self forKeyPath:@"status" options:0 context:&PlayerStatusContext];
Use the following code to play the music:
[self.player play];