I'm trying to play a .m4a sound file using AVQueuePlayer, on iPhone4, but there is no sound. If I try AudioServicesPlaySystemSound with the same file, all works okay.
Here's the code.
(AVFoundation framework is installed.)
#import <AVFoundation/AVFoundation.h>
-(void) play_sound_file: (NSString *) sound_file_m4a
{
printf("\n play_sound_file 1: '%s' ", [sound_file_m4a UTF8String] );
AVPlayerItem *sound_file = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:[[NSBundle mainBundle] pathForResource:sound_file_m4a ofType:@"m4a"]]];
AVQueuePlayer *player = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObjects:sound_file, nil]];
[player play];
return;
}
LATEST CODE AS OF 8/28/12........... (Note: both sound files work with AudioServicesPlaySystemSound)
AVPlayerItem *sound_file1 = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[NSString alloc] initWithFormat:@"Hold still"] ofType:@"m4a"]]];
AVPlayerItem *sound_file2 = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[NSString alloc] initWithFormat:@"Press go"] ofType:@"m4a"]]];
AVQueuePlayer *player = [AVQueuePlayer queuePlayerWithItems: [NSArray arrayWithObjects:sound_file1, sound_file2, nil]];
[player play];