2

My Live Radio URL is http://s2.yesstreaming.net:7091/stream and AVPlayer not able to play.

It's Live Radio Audio.

And it's my code.

@interface ViewController () {
    AVPlayer *player;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
    [[AVAudioSession sharedInstance] setActive:true error:nil];
    // Do any additional setup after loading the view, typically from a nib.
    player = [[AVPlayer alloc] init];
}

-(void)viewDidAppear:(BOOL)animated {
    AVPlayer *player123 = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:@"http://s2.yesstreaming.net:7091/stream"]];
    player.allowsExternalPlayback = true;
    player = player123;
}

- (IBAction)btnPayPauseAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        [player play];
    } else {
        [player pause];
    }
}
@end

The error is :

Task <70641693-CCCD-43C1-8A18-13A853FA3CD3>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=http://s2.yesstreaming.net:7091/stream, NSErrorFailingURLKey=http://s2.yesstreaming.net:7091/stream, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <70641693-CCCD-43C1-8A18-13A853FA3CD3>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <70641693-CCCD-43C1-8A18-13A853FA3CD3>.<1>, NSLocalizedDescription=cancelled} [-999]
Jaydip Godhani
  • 185
  • 2
  • 14

0 Answers0