AVAudioPlayer 播放没有声音解决方法

- (void)playVoice:(NSString*) voice type:(NSString*)type{

NSURL* url = [NSURLfileURLWithPath:[[NSBundlemainBundle]pathForResource:voiceofType:type]];

AVAudioPlayer* player = [[AVAudioPlayeralloc]initWithContentsOfURL:urlerror:nil];

player.volume=0.8;

[playerplay];

//_player = player; //第一种 使用全局变量保存 ,有声音  

//[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; //第二种没有声音,别的帖子上说可以解决,但是我试的时候还是没有声音

//sleep(2); //第三种,有声音

}

你可能感兴趣的:(AVAudioPlayer 播放没有声音解决方法)