【发布时间】:2015-08-17 04:53:02
【问题描述】:
我正在尝试播放位于远程服务器上某处的 mp3 文件。我有该音乐文件的 url 我已尝试使用 AVAudioPlayer 或 AVPlayer 播放它,但我无法播放 mp3 文件。请告诉我怎样才能播放 mp3 文件。
播放音乐的代码:
NSString *aSongURL = [NSString stringWithFormat:@"http://megdadhashem.wapego.ru/files/56727/tubidy_mp3_e2afc5.mp3"];
// NSLog(@"Song URL : %@", aSongURL);
AVPlayerItem *aPlayerItem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:aSongURL]];
AVPlayer *anAudioStreamer = [[AVPlayer alloc] initWithPlayerItem:aPlayerItem];
[anAudioStreamer play];
// Access Current Time
NSTimeInterval aCurrentTime = CMTimeGetSeconds(anAudioStreamer.currentTime);
// Access Duration
NSTimeInterval aDuration = CMTimeGetSeconds(anAudioStreamer.currentItem.asset.duration);
请告诉我该怎么做?
【问题讨论】:
标签: ios objective-c