iOS 7.0.3
我正在从URL加载mp3,当通过蜂窝(较慢)连接完成时,所有元数据都正确加载。
然而,当通过WiFi加载时,持续时间每次都为零。我试过添加观察者,等待readytoplay,初始化新的播放器等等。
我每次都有相同的结果:一切都在单元格上工作但不是wifi。
以下是我正在使用的代码片段,非常简单:
AVURLAsset *asset = [AVURLAsset assetWithURL: urlURL];
NSLog(@"Asset Duration: %lld", asset.duration.value);
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
NSLog(@"Item Duration: %lld", playerItem.duration.value);
audioPlayer = [AVPlayer playerWithPlayerItem:playerItem];
audioPlayer.currentItem.forwardPlaybackEndTime = CMTimeMake(self.audioPlayer.currentItem.asset.duration.value/self.audioPlayer.currentItem.asset.duration.timescale, 1);
[timeSlider setMaximumValue:self.audioPlayer.currentItem.asset.duration.value/self.audioPlayer.currentItem.asset.duration.timescale];
if (playButton.selected == YES){
[audioPlayer play];
}
如果有人能提出建议我会非常感激,这让我感到很沮丧!