-(voID)vIEwDIDLoad {[super vIEwDIDLoad];Nsstring* resourcePath = @"http://192.167.1.104:8888/SHREYA.mp3"; //your urlNSData *_objectData = [NSData dataWithContentsOfURL:[NSURL URLWithString:resourcePath]];NSError *error;audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:_objectData error:&error];audioPlayer.numberOfLoops = -1;if (audioPlayer == nil) NSLog([error description]); else [audioPlayer play];}解决方法 这应该工作:
NSURL *url = [NSURL URLWithString:@"<#live stream URL#>];// You may find a test stream at <http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8>.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];
使用以下代码播放音乐:
[self.player play];
@H_404_2@ 总结以上是内存溢出为你收集整理的如何在iPhone中使用URL链接播放音乐文件?全部内容,希望文章能够帮你解决如何在iPhone中使用URL链接播放音乐文件?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)