Я пытаюсь воспроизвести звуковой файл .m4a с помощью AVQueuePlayer на iPhone4, но звука нет. Если я попробую AudioServicesPlaySystemSound с тем же файлом, все работает нормально.
Вот код.
(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;
}
ПОСЛЕДНИЙ КОД ОТ 28.08.12........ (Примечание: оба звуковых файла работают с 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];