avplayer is not playing the URL

前端 未结 5 1449
长情又很酷
长情又很酷 2021-02-04 15:00

I am using avplayer for play audio url, but it is not working, I don\'t know where i am wrong

NSString *radioURL = @\"https://www.example.com\";

radioPlayer = [         


        
5条回答
  •  别那么骄傲
    2021-02-04 15:45

    Make Sure URL is AddingPercentEscapes.

    NSURL *audioURL = // Your Url;
    NSString *encodedString = [@"Your Url" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *myURL = [[NSURL alloc] initWithString:encodedString]
    AVPlayer *player = [AVPlayer playerWithURL:myURL];
    [player prepareToPlay];
    player play];
    

提交回复
热议问题