5

I have to change the audio output of an audio source , so that i could hear it from speaker not from headphones

I have no idea how to do it to be honest:) The code i use :

_audioSource.clip = Microphone.Start(Microphone.devices[0], false, 500, AudioSettings.outputSampleRate);

If i have my headphones plugged in ,the sound is going to play on them, which is not my goal

Maybe is something in Unity that i could use? Or just create an library in Android Studio

  • I don't think this is something Unity can handle? But I have no clue about android to be honest. But I saw you can change it with android scripts like [here](https://stackoverflow.com/questions/6834816/is-there-any-way-to-force-audio-through-the-speakers-when-headphones-are-plugged). Maybe there is a way to use this from Unity – derHugo Jan 14 '19 at 16:14
  • I guess this is something the operating system handles itself. Imagine every app doing different things. When you are having a call and plug in headphones you expect the voice being redirected. If every app would handle audio differently - how would you use your phone efficiently ? - so while you might be developing a game or anything else. Don't try to implement unexpected behavior. Imagine students in university start ur app and sound is doing random sh** :D – Felix D. Jan 15 '19 at 08:27
  • @derHugo thank you , in the final i'll try to make an java library to use the phone speaker. – Vlad Constantinescu Jan 15 '19 at 12:55
  • @FelixD. :)) yeah but i rly need to be able to plug an microphone(any type of microphone, not just headphones) (would be funny tho to see what you said in the final) – Vlad Constantinescu Jan 15 '19 at 12:57
  • @VladConstantinescu :P – Felix D. Jan 15 '19 at 13:03

0 Answers0