Nsstring *radioURL = @"https://www.example.com";radioPlayer = [AVPlayer playerWithURL:[NSURL URLWithString:radioURL]] ;// [radioPlayer seektotime:kCMTimeZero];NSLog(@"radio player %@",radioPlayer.currentItem);[radioPlayer play];
任何帮助,将不胜感激.
解决方法 我强烈推荐下面的代码来播放无线电流:请看一下 AVPlayer_Class-(voID)Play{ Nsstring *radioURL = @"https://www.example.com"; //this url must valID AVPlayer *player = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:radioURL]]; self.songPlayer = player; //self.songPlayer is a globle object of avplayer [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(playerItemDIDReachEnd:) name:AVPlayerItemDidplayToEndTimeNotification object:[songPlayer currentItem]]; [self.songPlayer addobserver:self forKeyPath:@"status" options:0 context:nil];}- (voID)observeValueForKeyPath:(Nsstring *)keyPath ofObject:(ID)object change:(NSDictionary *)change context:(voID *)context { if (object == songPlayer && [keyPath isEqualToString:@"status"]) { if (songPlayer.status == AVPlayerStatusFailed) { NSLog(@"AVPlayer Failed"); } else if (songPlayer.status == AVPlayerStatusReadytoplay) { NSLog(@"AVPlayerStatusReadytoplay"); [self.songPlayer play]; } else if (songPlayer.status == AVPlayerItemStatusUnkNown) { NSLog(@"AVPlayer UnkNown"); } } }- (voID)playerItemDIDReachEnd:(NSNotification *)notification { // code here to play next sound file }
参考链接是 – Streaming mp3 audio with AVPlayer
总结以上是内存溢出为你收集整理的ios – avplayer没有播放网址全部内容,希望文章能够帮你解决ios – avplayer没有播放网址所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)