问题
I am working on a half-duplex VOIP call app. In that I am trying to play tones along-with vibration during floor exchanges - floor exchanges are done to change the talker from A to B or vice-versa for a half-duplex call. If I try to play tones using AudioServicesPlayAlertSound, then it plays sound when user gets the call, but not during floor exchanges, due to possible mixing issues with call audio. So I replaced AudioServicesPlayAlertSound with AVAudioPlayer's play function. So, now I am able to play the tones perfectly during the call, i.e. during the floor exchanges, i.e. it mixes well with the VOIP call audio. However if I try to add vibrate functionality using AudioServicesPlayAlertSound, it does not vibrate the device, the function gets called but it doesn't take into effect. If I comment out AVAudioPlayer's function to play the tone, then the vibrate function works. Can somebody please suggest what I am missing ?
SNIPPET:
NSLog(@"Play toneIncoming");
[_audioPlayerIncoming setDelegate:self];
[_audioPlayerIncoming play];
NSLog(@"vibrate now");
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
//OR AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
I tried above 2 functions for vibrate, but they work only if I comment out AVAudioPlayer's play function, but I need to play a specific tone for different events for VOIP call, so I need that functionality too.
来源:https://stackoverflow.com/questions/17055344/ksystemsoundid-vibrate-not-working-with-avaudioplayer-play