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

moonman239

Cancelled
Original poster
Code:

AVQueuePlayer+initWithAppAudioFiles.m
Code:
#import "AVQueuePlayer+initWithAppAudioFiles.h"

@implementation AVQueuePlayer (initWithAppAudioFiles)
+(AVQueuePlayer *)initWithAppFiles:(NSArray *)fileNames extension:(NSString *)extension
{
    NSMutableArray *fileURLs;
    for (NSString *fileName in fileNames)
    {
        NSURL *fileURL = [[NSBundle mainBundle] URLForResource:fileName withExtension:extension];
        [fileURLs addObject:fileURL];
    }
    AVQueuePlayer *queuePlayer = [[AVQueuePlayer alloc] initWithItems:fileURLs];
    return queuePlayer;
}
@end
 
Last edited:
Looks like the problem lies with the following code:

Code:
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:fileName withExtension:extension];

Even though the file names and extensions are correct, fileURL remains nil.
 
How did you add the files to your project? When using the File > Add Files to "ProjectName"... option (or dragging-and-dropping), you should make sure you have checked the proper target in the "Add to targets" section of the dialog. If so, this will automatically add the file to the Copy Bundle Resources settings.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.