0
我有播放聲音的應用程序。他們在iPad Air 10.3.1上運行良好,但不在我的iPhone 7 10.3.1上運行。我嘗試了不同的音頻格式,iPhone 7上沒有播放任何內容。有沒有在plist中輸入一些內容或者我需要在iPhone 7上播放聲音?聲音不能在iPhone 7上播放iOS 10
ViewController.h
@property (strong,nonatomic) AVAudioPlayer *player;
ViewController.m
- (void)viewDidAppear:(BOOL)animated {
NSError *err;
NSURL *url = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"]];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err];
if (err) NSLog(@"error");
player.volume = 1.0;
player.delegate = self;
[player prepareToPlay];
[player play];
NSLog(@"sound should have played");
}