AVQueuePlayer - random crash

Discussion in 'iOS Programming' started by NikitaTrophimov, Apr 29, 2013.

  1. NikitaTrophimov macrumors newbie

    Joined:
    Apr 29, 2013
    #1
    Why does the following sample code that uses AVQueuePlayer crashes randomly on the certain songs, but works ok on the others? What am i doing wrong?

    Code:
    // ViewController.h
    
    #import <AVFoundation/AVFoundation.h>
    #import <UIKit/UIKit.h>
    
    @interface ViewController : UIViewController
    
    @property AVPlayerItem *playerItem;
    @property AVQueuePlayer *queuePlayer;
    
    - (IBAction)buttonPressed:(id)sender;
    - (void)checkStatus;
    
    @end
    Code:
    // ViewController.m
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    @synthesize playerItem = _playerItem;
    @synthesize queuePlayer = _queuePlayer;
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
    }
    
    - (IBAction)buttonPressed:(id)sender
    {
        self.playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://cs5107.vk.me/u46779903/audios/34ba1ede2b0e.mp3"]];
    
        NSArray *playerItemsArray = [NSArray arrayWithObject:self.playerItem];
        if (!self.queuePlayer)
        {
            self.queuePlayer = [AVQueuePlayer queuePlayerWithItems:playerItemsArray];
        }
        else
        {
            [self.queuePlayer insertItem:self.playerItem afterItem:nil];
            [self.queuePlayer advanceToNextItem];
        }
        [self.queuePlayer play];
    }
    @end
    If you'll run this code, you'll notice that it could crashed on the first try or on the second. Or maybe later...

    I've got the following call stack and description in Xcode:

    https://imageshack.us/a/img826/8466/crashd.png
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Actually, when I ran this code, nothing happened; it didn't crash either. But that's because I get a "404 Page Not Found" from the http://cs5107.vk.me/u46779903/audios/34ba1ede2b0e.mp3 URL.
     
  3. NikitaTrophimov thread starter macrumors newbie

    Joined:
    Apr 29, 2013
    #3
    Oh, sorry, it seems like you need to login to vk.com first.

    Do you have any assumptions anyway?
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    No, not really.
     
  5. NikitaTrophimov thread starter macrumors newbie

    Joined:
    Apr 29, 2013
    #5
    How can i check if the audio stream is valid?
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    I see you posted this same question on StackOverflow. You shouldn't cross-post.

    Good luck with figuring out the crash.
     

Share This Page