0

I cannot play my sound which is m4a apple format. I thought the format was supported though. Any idea that could help ? Thank you !

#import "PhoneViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface PhoneViewController ()
@property (strong, nonatomic) AVAudioPlayer *optique2000Audio;
@end

@implementation PhoneViewController

- (IBAction)cinq {
    NSString *backgroundMusicPath = [[NSBundle mainBundle] pathForResource:@"optique2000" ofType:AVFileTypeAppleM4A];
    NSURL *backgroundMusicURL = [NSURL URLWithString:backgroundMusicPath];
    NSError *error;
    self.optique2000Audio = [[AVAudioPlayer alloc] initWithContentsOfURL:backgroundMusicURL error:&error];
    [self.optique2000Audio play];
}

@end
4

1 回答 1

0

请务必在您的设备而不是模拟器上对其进行测试。在您的模拟器工作之前,需要对它进行一些配置。我不确定它是否与 m4a 格式相关联。有关更多信息,请参阅此答案

迄今为止发现的最佳教程:http ://www.tutorialspoint.com/ios/ios_audio_video.htm

于 2014-03-27T01:00:25.220 回答