Closed regentcid434 closed 7 years ago
Yeah same issue here. Anyone know a solution?
I'm having this same issue also. Any solution would be great.
We need to implement it. We have it on our roadmap so it'll surely be taken care of.
Is this something we could help with if you pointed us in that direction?
@regentcid434, that'd be awesome! I haven't finished with the research so there's that part to be completed before we jump to a specific implementation. What I've read on the Internet is the following. On the Web with the JavaScript WebRTC API we'd have these as separate output devices. The native WebRTC API doesn't provide such a direct way and merely picks some output as default so one has to instruct the underlying audio output used by the native WebRTC API to switch to the speaker. I may be wrong though. We need to finish this research, see what others are doing, probably modify react-native-webrtc so that we have a semblance of the Web/JavaScript WebRTC API implemented there.
The native code is a bit out of my realm, but I seem to have gotten it working for my use case by adding in react-native-incall-manager and using it to force the audio to use the speaker once the connection has been established and then reverting after disconnecting. It's not ideal, but even WebRTC currently recommends using it for native control. I've only used this in iOS so far, but it was very little code. Hopefully, it will be robust across platforms.
If this is something people would find useful, I could put in a pull request or share the code for critique.
I found a quick solution and already tried in my project, it works well
iOS:
In project RCTWebRTC
File WebRTCModule+RTCDataChannel.m
Method: - (void)dataChannel:(RTCDataChannel *)channel didReceiveMessageWithBuffer:(RTCDataBuffer *)buffer
add these lines of code in the bottom of this method
NSError *error = nil;
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord
withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker
error:&error];
Android (it is more complicated a bit):
In project react-native-webrtc
Class: WebRTCModule
add more declarations as below:
public static final String ACTION_DATA_CHANNEL_RCVMSG = "com.oney.WebRTCModule.action.datachannelrcvmsg";
public void onDataChannelReceiveMessage() {
Intent intent = new Intent(ACTION_DATA_CHANNEL_RCVMSG);
getReactApplicationContext().sendBroadcast(intent);
}
Class: DataChannelObserver
Method: onMessage
add this line of code in the bottom of method
webRTCModule.onDataChannelReceiveMessage();
Finally, in your custom class ReactActivity
, handle this broadcast event ACTION_DATA_CHANNEL_RCVMSG
. For example:
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
switch (action) {
case ACTION_DATA_CHANNEL_RCVMSG: {
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
boolean useHeadphone = am.isWiredHeadsetOn();
am.setMode(AudioManager.MODE_IN_CALL);
am.setSpeakerphoneOn(!useHeadphone);
break;
}
}
}
};
Oops, this is old :-) We now default to the speaker for video calls and switch to the earpiece for audio-only mode is enabled.
I have added bundle config as below
Bundle config = new Bundle(); config.putBoolean("startAudioOnly", true); Bundle urlObject = new Bundle(); urlObject.putBundle("config", config); urlObject.putString("url", "https://meet.jit.si/demo"); view.loadURLObject(urlObject); setContentView(view);
call starts as audio only, but audio gets routed to speaker, instead of earphone, and i press on select the sound device, i only get the option of "Speaker". and if i start the jitsi-meet android app(downloaded from play store) and start the voice only call, it works as expected. What am i missing?
@carotkut94 did you found any solution to this?
@saghul this is still a problem and audio calls are not using earpiece as default.
@kaswan24 @erandakarachchi Did you find solution for earphones instead of default speaker?
@saghul this is still a problem and audio calls are not using earpiece as default.
@saghul this is still a problem and audio calls are not using earpiece as default.
That's intentional and by design, not a problem.
@saghul any workaround this? or atleast any way to move the audio output select button to toolbar so it is quick to access and switch to earpiece ?
It's now on the title bar, so no longer one menu away.
umm, what do i have to add in toolbarButtons to get this? I can't see anything regarding output devices.
Not sure it made it to the latest SDK release but we'll be releasing a new one very soon. This is how it looks like:
Got it. Thanks
Running on an iPhone, the audio in a conference only uses the ear speaker and not the speaker phone. Holding the phone to your ear defeats the purpose of using the camera. Is there a way to change this?