Giter Club home page Giter Club logo

Comments (20)

saghul avatar saghul commented on July 3, 2024 4

The WebRTC library is managing the system AVAudioSession on its own, so you have to use the audioroute plugin right after audio starts playing (you can technically do it a bit earlier, but anyway) because otherwise (libwebrtc) it will change your route.

Google has plans to allow for a more manual control of this, but that work hasn't landed in libwebrtc yet, so we have to juggle with timing.

from cordova-plugin-iosrtc.

ibc avatar ibc commented on July 3, 2024

Good point. However, there is nothing in the libwebrtc Objective-C API to select which audio output to use for a RTCAudioTrack. Even worse, once a PeerConnection is connected and a remote MediaStream is generated, the audio track of the the mediastream is just magically "rendered". I mean: the plugin does absolutely nothing with the RTCAudioTrack.

Just check the code to realize that nothing is being explicitly donde with the audio track of a RTCMediaStream.

BTW this is something to report to the Google's libwebrtc project. I'll do it in the next days.

from cordova-plugin-iosrtc.

ibc avatar ibc commented on July 3, 2024

For now I've just sent a mail to discuss-webrtc asking about this topic:

https://groups.google.com/forum/#!topic/discuss-webrtc/q4bttvVMB4I

from cordova-plugin-iosrtc.

markharding avatar markharding commented on July 3, 2024

I'm currently getting around this by adding

var session: AVAudioSession = AVAudioSession.sharedInstance()
session.overrideOutputAudioPort(AVAudioSessionPortOverride.Speaker, error: nil);

on render.

from cordova-plugin-iosrtc.

ibc avatar ibc commented on July 3, 2024

How does that work? Should I call that for each new "call"? should that session variable be referenced not to be garbage collected?

from cordova-plugin-iosrtc.

jclardy avatar jclardy commented on July 3, 2024

So is it possible to use that to create some sort of toggle on the javascript side? Can it be called while the session is active?

from cordova-plugin-iosrtc.

jclardy avatar jclardy commented on July 3, 2024

@ibc I don't think you would need to reference the session variable, as it is a singleton, so just grabbing the sharedInstance() every time should be fine.

from cordova-plugin-iosrtc.

ibc avatar ibc commented on July 3, 2024

OK, I will add a JS binding for calling that method.

from cordova-plugin-iosrtc.

ibc avatar ibc commented on July 3, 2024

This is implemented in 1.2.6: 8b55797

from cordova-plugin-iosrtc.

markharding avatar markharding commented on July 3, 2024

One problem with this solution is that iOS will force the speaker when a user has headphones plugged in.

from cordova-plugin-iosrtc.

ibc avatar ibc commented on July 3, 2024

There may be a Cordova plugin that detects headphones plugged in.

from cordova-plugin-iosrtc.

saghul avatar saghul commented on July 3, 2024

Anyone running into this, you might be interested in https://github.com/saghul/cordova-plugin-audioroute

from cordova-plugin-iosrtc.

cozzbie avatar cozzbie commented on July 3, 2024

Hi @ibc was wondering if you could show in your docs how to use @saghul Audioroute plugin to route audio to speakers. I know he said something detecting AVAudioSession but I really have no clue where to start from. Thanks

from cordova-plugin-iosrtc.

ibc avatar ibc commented on July 3, 2024

@cozzbie I have no idea.

from cordova-plugin-iosrtc.

cozzbie avatar cozzbie commented on July 3, 2024

tears, sobs and pain Thank you. @ibc

from cordova-plugin-iosrtc.

oscarvadillog avatar oscarvadillog commented on July 3, 2024

@cozzbie You can try something like that:

cordova.plugins.audioroute.overrideOutput('speaker', 
  function(success) {
    // Success
  },
  function(error) {
    // Error
  }
);

from cordova-plugin-iosrtc.

cozzbie avatar cozzbie commented on July 3, 2024

Already doing that but it doesn't work. Was thinking maybe it was the line I was calling it from so I asked @saghul and he said we should listen for AVAudioSession something and I am at a loss as to how to go about that. @oscarvadillog

from cordova-plugin-iosrtc.

magestican avatar magestican commented on July 3, 2024

Audio is not coming through the specified device on my ipad when I specify speaker as the audio output ussing audioroute plugin @oscarvadillog @saghul

from cordova-plugin-iosrtc.

isaax2 avatar isaax2 commented on July 3, 2024

it works with the plugin mentioned by, @oscarvadillog

just call it after the audio session was established, for example for a working test, copy and paste after your videocall was established in safari's console.

cordova.plugins.audioroute.overrideOutput('speaker',
function(success) {
// Success
alert("success");
console.log("success",success);
},
function(error) {
// Error
alert("error");
console.log("error",error);
}
);

from cordova-plugin-iosrtc.

AmrAbdalrahman avatar AmrAbdalrahman commented on July 3, 2024

solved with me by using this plugin cordova-plugin-audioinput .

PS: in case of make a video call after remote stream added make

setTimeout(() => {
AudioToggle.setAudioMode(AudioToggle.SPEAKER);
}, 2000);
}

from cordova-plugin-iosrtc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.