バッファリングが必要ない場合は、MPMovieviewcontroller を介してストリーミング ライブ オーディオを再生してみてください。
オーディオ/ビデオのライブ ストリーミングに最適なプレーヤーです。私もこのプレーヤーを使用しています
ライブ オーディオ ストリーミングを再生するためのアプリ。あなたのすべての要件はこれと一致すると思います。実装してみる
それを理解してください。実装も簡単です.Hereを使用してストリームオーディオを再生するコードを次に示します
MPMovieviewcontroller:
NSURL *fileURL=[NSURL URLWithString:geturl];
NSLog(@"fileURL..%@",fileURL);
moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
[moviePlayerController.moviePlayer prepareToPlay];
moviePlayerController.moviePlayer.shouldAutoplay=YES;
moviePlayerController.view.frame = self.view.frame;
[self presentMoviePlayerViewControllerAnimated:moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayerDidExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
[moviePlayerController.moviePlayer play];
- (void)MPMoviePlayerDidExitFullscreen:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerDidExitFullscreenNotification
object:nil];
[moviePlayerController.moviePlayer stop];
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[moviePlayerController dismissMoviePlayerViewControllerAnimated];
}
バックグラウンド再生のために、これらの行を info.plist に追加します。これらも plist に追加します。