Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I am having a problem. I am creating a brand new app (just started today). In this app, I have an AVQueuePlayer that is supposed to play some sounds when a the user drags a label to a certain point on the screen. The problem is that not all sounds are playing. At some point, the first three sounds in the code below did play, but not the last one.

The code below is not the real code; I renamed some variables to ensure nobody has any clue what this app does.

Code:
-(void)label:(UILabel *)label wasDraggedToPoint:(CGPoint)point
{
    CGRect frame = [[self blankLabel] frame];
    if (CGRectContainsPoint(frame, point)) {
        NSString *blank = [NSString stringWithFormat:@"%@%@",[label text],blankblah];
        if ([blank isEqualToString:string]) {
            NSLog(@"%@",@"Correct answer.");
            
        }
        else
        {            for (DraggableLabel *label in [self draggableLabels])
            {
                [label setCenter:[label originalLocation]];
            }
            for (NSInteger i=0; i<=[correctString length] -1; i++)
            {
                NSRange blahRange = NSMakeRange(i, 1);
                NSString *blah = [correctString substringWithRange:blahRange];
                NSURL *itemURL = [[NSBundle mainBundle] URLForResource:blah withExtension:@"m4a" subdirectory:@"sounds"];
                AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:itemURL];
                [[self queuePlayer] insertItem:item afterItem:nil];
            }
            [[self queuePlayer] insertItem:correctblankPlayerItem afterItem:nil];
            [[self queuePlayer] play];
        }
    }
}

Edit: I should add that my app does have a method that is called whenever the queue player's currentItem key changes, but this is not the cause of my problem.

Oh, and the view controller that causes this code to be run has a strong reference to the queue player.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.