接收器扬声器没有运行声音

时间:2016-08-26 06:30:57

标签: ios objective-c

调用rececive在接收器speacker中播放声音但不是错误accer而不是声音在设备中播放任何一个speacker来解决这个问题。

NSString *voice=[[NSUserDefaults standardUserDefaults] objectForKey:TB_Voice_conversation_value];
NSError *error;
BOOL Errors;

NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:voice];
NSURL *myFileURL = [NSURL fileURLWithPath:filePath];

AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:myFileURL error:nil];
[player setDelegate:self];

AVAudioSession *session = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription *route = [session currentRoute];
NSLog(@"output : %@", route.outputs);

Errors = [session  overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];
[session setActive:YES error:&error];

[player play];
if (!Errors)
{
    NSLog(@"Error:%@",error);
}

提前谢谢。

0 个答案:

没有答案