How to play MP3 From URL in iOS

大城市里の小女人 提交于 2020-01-16 04:05:31

问题


This question seem to duplicate with many questions. I have followed many answer in those questions already but non of them working for me. So I decided to ask this question again if you an help me. I have a URL that I get from a webview

[[[webview request]URL]absoluteString];

and here is my code to play the MP3 file from URL:

// properties
@property (strong,nonatomic) AVPlayerItem *playerItem;
@property (strong,nonatomic) AVPlayer *player;

// coding
NSString *decoded = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (CFStringRef)aSongURL, CFSTR(""), kCFStringEncodingUTF8);
NSURL *aURL = [NSURL URLWithString:decoded];
self.playerItem = [AVPlayerItem playerItemWithURL:aURL];
self.player = [AVPlayer playerWithPlayerItem:self.playerItem];
self.player = [AVPlayer playerWithURL:aURL];
[self.player play];

Please Help Me

Edit

//output
aURL = "http://laguboard.com/music/down/33867378/2794942/NTU0NktpZE56eERWZGxVeC9zTS9LVUd1TEhkZTE0cFZuaW1QS1pFMHVhOUNkM2ZoZEE=/(http://mp3xload.wapka.me).mp3"

来源:https://stackoverflow.com/questions/33862697/how-to-play-mp3-from-url-in-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!