【发布时间】:2013-10-21 03:06:55
【问题描述】:
我正在使用 AVPlayer 播放长音频 mp3 流音乐(8 分钟),短音乐(1 到 3 分钟)播放完美,但随着这些更大的音乐开始播放音乐,但在播放一些随机分钟后(2 到3:20) 播放器从头开始播放曲目。虽然播放器重启了音乐,但状态信息(持续时间和当前时间)一直正常计数,没有重启,只是音频重启。有人有想法吗?
我正在播放的文件是这样的:http://storage-new.newjamendo.com/download/track/57864/mp31/
播放器代码:
AVAudioSession *mySession = [AVAudioSession sharedInstance];
// Assign the Playback category to the audio session.
NSError *audioSessionError = nil;
[mySession setCategory: AVAudioSessionCategoryPlayback
error: &audioSessionError];
if (audioSessionError != nil) {
NSLog (@"Error setting audio session category.");
return;
}
// Activate the audio session
[mySession setActive: YES
error: &audioSessionError];
if (audioSessionError != nil) {
NSLog (@"Error activating audio session during initial setup.");
return;
}
player = [AVPlayer playerWithURL:[NSURL URLWithString:url]];
[player play];
这就是我如何跟踪有关当前时间的信息,它会保持正常计数。
AVPlayerItem *item = player.currentItem;
CMTime duration = [item duration];
CMTime currentTime = [item currentTime];
【问题讨论】:
-
可能和你的音乐来源有关,我是用AVplayer来播放soundcloud音乐的,没有任何问题
-
@NicolasManzini 我已经尝试使用相同的音乐源在互联网(github)上使用其他自定义播放器,但它没有发生,只是使用 AVPlayer。
标签: iphone objective-c ios7 audio-streaming avplayer