kSystemSoundID_Vibrate not working with AVAudioPlayer Play

微笑、不失礼 提交于 2021-02-19 02:04:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!