質問

I'm pretty confused by this one and can't think of anything obvious that I am doing wrong.

I can't get iOS to pull an m4a out of my app bundle

eg

NSURL *clickurl = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/fishy2.m4a", [[NSBundle mainBundle] resourcePath]]];

NSError *error;

audioPlayer = [[AVAudioPlayer alloc] 
                   initWithContentsOfURL:clickurl
                   error:&error];

audioPlayer.delegate = self;

if (error)
        NSLog(@"Error: %@", 
              [error localizedDescription]);
else
        [audioPlayer play];

I get an error -43

However, if I instead use an identical mp3 instead

NSURL *clickurl = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/fishy.mp3", [[NSBundle mainBundle] resourcePath]]];

everything is happy

I've tried this many many times across different projects and can't see where I'm going wrong. I've been using NSFileManager to check if it is there and it says no to the m4a, but yes to the mp3. Tried this with all manner of different methods of importing different audio files in different formats and I can't seem to get it to find the m4a (and it really really has to be m4a). mp3, wav, caf etc... all work. Interestingly, the m4as that I run from the user documents directory work just fine

All I want is to be able to copy the file!

Any ideas at all?

役に立ちましたか?

解決

Work around = right click and "add files to " instead of dragging

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top