我有一个iOS应用程序播放一个AVPlayer背景配乐和“顶”起其他的声音片段与第二AVPlayer。 (声音片段都是从网上流,因此需要对AVPlayer)。问题是,第二AVPlayer开始播放时,它会导致后台AVPlayer停一秒钟,类似于在此评论中描述的一小部分:
播放多种音频文件与AVPlayer
我准备用这种方法的音频片段:
- (void)prepareAudio:(NSURL *)assetURL {
asset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
playerItem = [AVPlayerItem playerItemWithAsset:asset];
[player replaceCurrentItemWithPlayerItem:playerItem];
[playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
[playerItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[player currentItem]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemFailedToReachEnd:)
name:AVPlayerItemFailedToPlayToEndTimeNotification
object:[player currentItem]];
}
...然后调用[player play];
当我想听到的每个声音。
有什么我需要做的,当我设置音频会话或AVPlayer的每个实例,使声音不融合的故障?