1

I am using AVQueuePlayer for playing multiple music file.

I am using this code,

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];

But application crashes while playing first audio with lldb in console log. This is the screenshot for help. I think it is something about memory management.

Any help will be appreciated. Thank you.

iUser
  • 1,075
  • 3
  • 20
  • 49
  • the code snippet you posted looks fine. are you using ARC? if not: where do you release the myQueue? – Daij-Djan Jan 10 '13 at 12:35
  • and in what thread are you? – Daij-Djan Jan 10 '13 at 12:37
  • Yes, i am using arc but disabled for this class after getting this error. Releasing myQueue in `- (void)playerItemDidReachEnd:(NSNotification *)notification { [myQueue release]; }` and also tried to add next audio here. But again it crashes after playing one audio. – iUser Jan 10 '13 at 13:17
  • dont release it there, thats too early – Daij-Djan Jan 10 '13 at 15:22
  • So, where should i release `myQueue`? Do you have any other suggestion? – iUser Jan 11 '13 at 06:26

2 Answers2

0

you are not using ARC you said and you are saying that you release myQueue in playerItemDidReachEnd which is too early.. youa aren't DONE with the queue and should keep it retained until you are.

Release it when your class is deallocated

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
0

Enable ARC, Try going into Breakpoints in XCode, and replace the All Exceptions with All Objective-C Exceptions and see if it happens again.

I'm using AVQueuePlayer heavily and noticed a bunch of exceptions in the framework code during play, but the file still plays fine.

kain
  • 5,510
  • 3
  • 27
  • 36