ios - Force Built-in Mic over bluetooth headset's mic? -
i use built-in mic on device input , bluetooth headset output. session category , must avaudiosessioncategoryplayandrecord
. have tried using setpreferredinput:
built-in mic switches output device's speakers.
i've seen this (specifically comments) mention it's possible.
you can use code
// create , set audio session avaudiosession* audiosession = [avaudiosession sharedinstance]; [audiosession setdelegate:self]; [audiosession setcategory: avaudiosessioncategoryplayandrecord error: nil]; [audiosession setactive: yes error: nil]; // set bluetooth microphone input uint32 allowbluetoothinput = 1; osstatus stat = audiosessionsetproperty ( kaudiosessionproperty_overridecategoryenablebluetoothinput, sizeof (allowbluetoothinput), &allowbluetoothinput ); nslog(@"status = %x", stat); // problem if not 0 // check audio route uint32 size = sizeof(cfstringref); cfstringref route; osstatus result = audiosessiongetproperty(kaudiosessionproperty_audioroute, &size, &route); nslog(@"route = %@", route); // if bluetooth headset connected, should "headsetbt" // if not connected, "receiverandmicrophone" // now, play quick sound put in bundle (bomb.wav) cfbundleref mainbundle = cfbundlegetmainbundle(); cfurlref soundfileurlref; systemsoundid soundfileobject; soundfileurlref = cfbundlecopyresourceurl (mainbundle,cfstr ("bomb"),cfstr ("wav"),null); audioservicescreatesystemsoundid (soundfileurlref,&soundfileobject); audioservicesplaysystemsound (soundfileobject);
Comments
Post a Comment