【发布时间】:2013-01-10 12:25:26
【问题描述】:
我正在使用AVQueuePlayer 播放多个音乐文件。
我正在使用此代码,
NSString *str1 = @"www.mymusic.1.mp3";
NSURL *url1 = [NSURL URLWithString:str1];
AVPlayerItem *s1 = [AVPlayerItem playerItemWithURL:url1];
NSString *str2 = @"www.mymusic.2.mp3";
NSURL *url2 = [NSURL URLWithString:str2];
AVPlayerItem *s2 = [AVPlayerItem playerItemWithURL:url2];
myQueue = [[AVQueuePlayer alloc] initWithItems:[NSArray arrayWithObjects:s1,s2, nil]];
[myQueue play];
但在控制台日志中使用lldb 播放第一个音频时应用程序崩溃。
这是寻求帮助的屏幕截图。我认为这与内存管理有关。
任何帮助将不胜感激。谢谢。
【问题讨论】:
-
您发布的代码 sn-p 看起来不错。你在用ARC吗?如果没有:你在哪里释放 myQueue?
-
你在哪个线程?
-
是的,我正在使用 arc,但在收到此错误后禁用了此类。在
- (void)playerItemDidReachEnd:(NSNotification *)notification { [myQueue release]; }中释放 myQueue 并尝试在此处添加下一个音频。但它在播放一个音频后再次崩溃。 -
不要在那里发布,太早了
-
那么,我应该在哪里释放
myQueue?您还有什么建议吗?
标签: iphone xcode memory-management audio-streaming avqueueplayer