AVPlayer не может воспроизвести Live Radio URL - PullRequest
0 голосов
/ 16 ноября 2018

URL-адрес моего прямого эфира - http://s2.yesstreaming.net:7091/stream, а AVPlayer не может воспроизводить.

Это радио в прямом эфире.

И это мой код.

@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

Ошибка:

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]
...