我在ipod-library中有网址://item/item.mp3?id = 8788117795090152241 如何在这个网址中播放mp3
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:url_selectedSong];
AVPlayer *player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
[player play];
但不是播放歌曲
答案 0 :(得分:1)
使用此:
NSError * error;
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
if(player) {
[player play];
}