How to play MP3 From URL in iOS

2019-08-06 03:27发布

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"

0条回答
登录 后发表回答