jitsi / jitsi-meet

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
https://jitsi.org/meet
Apache License 2.0
22.87k stars 6.69k forks source link

Audio output defaults to ear speaker #1171

Closed regentcid434 closed 7 years ago

regentcid434 commented 7 years ago

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?

coosamatt commented 7 years ago

Yeah same issue here. Anyone know a solution?

pcw0002 commented 7 years ago

I'm having this same issue also. Any solution would be great.

lyubomir commented 7 years ago

We need to implement it. We have it on our roadmap so it'll surely be taken care of.

regentcid434 commented 7 years ago

Is this something we could help with if you pointed us in that direction?

lyubomir commented 7 years ago

@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.

regentcid434 commented 7 years ago

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.

caomanhquang commented 7 years ago

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;
                }
            }
        }
    };
saghul commented 7 years ago

Oops, this is old :-) We now default to the speaker for video calls and switch to the earpiece for audio-only mode is enabled.

carotkut94 commented 5 years ago

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?

erandakarachchi commented 4 years ago

@carotkut94 did you found any solution to this?

kaswan24 commented 3 years ago

@saghul this is still a problem and audio calls are not using earpiece as default.

saqibomer commented 3 years ago

@kaswan24 @erandakarachchi Did you find solution for earphones instead of default speaker?

toseef31 commented 3 years ago

@saghul this is still a problem and audio calls are not using earpiece as default.

saghul commented 3 years ago

@saghul this is still a problem and audio calls are not using earpiece as default.

That's intentional and by design, not a problem.

kaybhutani commented 2 years ago

@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 ?

saghul commented 2 years ago

It's now on the title bar, so no longer one menu away.

kaybhutani commented 2 years ago

umm, what do i have to add in toolbarButtons to get this? I can't see anything regarding output devices.

saghul commented 2 years ago

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:

image

kaybhutani commented 2 years ago

Got it. Thanks