我想在从 URL 流式传输 mp3 并将其打印到 IULabel 时监视下载的字节。我找不到任何简单的方法来做到这一点。
“AVPlayerItemAccessLog”呢,它有信息吗?我不知道如何使用它?有人知道如何获取此类信息吗?
以下是我播放流的代码:
-(void)play
{
/*Allow radio to run in background*/
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
/*Gets the url fra sender*/
NSString *urlString= self.radioStation.url;
NSURL *url = [NSURL URLWithString:urlString];
/*Stop the radio if its play or have info*/
if(self.avPlayerItem)
{
[self stop];
}
/*Sets the Avplayeritem*/
self.avPlayerItem = [AVPlayerItem playerItemWithURL:url];
/*Listen for changes in the avPlayerItem*/
[self.avPlayerItem addObserver:self forKeyPath:@"status" options:0 context:nil];
/*Sets the avplayer with avplayeritem*/
self.avPlayer = [AVPlayer playerWithPlayerItem:self.avPlayerItem];
/*Sends loading info to the nortification*/
[[NSNotificationCenter defaultCenter] postNotificationName:@"Loading" object:self];
/*Plays the radio*/
[self.avPlayer play];
}