呼叫接收到接收器播放声音

调用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); } 

谢谢你。