Je ne pense pas que AVAudioPlayer supporte les mp3 en streaming. D'après mon expérience, je suis raisonnablement confiant en disant qu'il ne joue que des fichiers locaux.
J'ai lu des fichiers mp3 distants en utilisant AVPlayer.
self.player = [[AVPlayer alloc] initWithURL:fileURL];
//inits the AVPlayer object.
[player addObserver:self forKeyPath:@"status" options:0 context:nil];
// You need to watch for for when the player obeject becomes ready to play, using key-value observation
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if(object == player && [keyPath isEqualToString:@"status"])
{
playButton.enabled = YES;
playButton.titleLabel.text = @"Play";
.....
//do whatever you need to do here to get the object ready to play.
}
}
Un simple [lecture du lecteur] commencera la lecture du fichier.
//metadata is available at
player.currentItem.asset.commonMetadata
//and time played can be calculated by dividing x by y
UInt64 x = self.player.currentTime.value;
int32_t y = self.player.currentTime.timescale;
int secs = x/y;