Issue
I am developing an Ionic app with the ApiRTC library for video chat functionality. However, the video audio comes out the headset speaker on phones, where I want it to come out the main speaker. The ApiTRC Cordova FAQ suggests using the AudioToggle plugin, so that is what I am attempting to import into my project.
To import I did ionic cordova plugin add cordova-plugin-audiotoggle --save
in the root of my project directory. Then I attempted to call the plugin in my code like this:
declare var AudioToggle;
constructor(public navCtrl: NavController, public navParams: NavParams...) {
AudioToggle.setAudioMode(AudioToggle.EarPiece);
}
However, it says AudioToggle is undefined and a function "setAudoMode" does not exist for "undefined."
Am I importing a Cordova plugin the wrong way, or is something else wrong?
Solution
I got it working by declaring the plugin, and then only setting the audio mode when I started an audio event (video call in my case).
declare var AudioToggle;
startVideoCall(){
AudioToggle.setAudioMode(AudioToggle.SPEAKER);
//Do other code...
}
Answered By - Andrew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.