我有一个iOS应用程序,播放一个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]];
}
Run Code Online (Sandbox Code Playgroud)
......然后[player play];在我想听到每个声音的时候调用.
当我设置音频会话或AVPlayer的每个实例时,我需要做些什么,以便声音在没有故障的情况下融合?
我知道有很多关于'强'与'弱'的写作.但是所有的文档都说两者都是100%的同义词,你可以用'strong'代替'retain',反之亦然.
我的问题是:如果它们相同,为什么Apple会引入新的"强"关键字?我已在一个示例项目中测试了两者,并且'strong'和'retain'属性属性似乎都做同样的事情.难道你不认为如果Apple引入了"强"属性,它应该禁止使用'retain'属性吗?或者我错过了什么?
memory-management properties objective-c ios automatic-ref-counting