alongubkin / audiotoggle Goto Github PK
View Code? Open in Web Editor NEWCordova plugin for switching between speaker and earpiece when playing audio
License: Apache License 2.0
Cordova plugin for switching between speaker and earpiece when playing audio
License: Apache License 2.0
Hey,
Hopefully, you are doing well. I got an issue that I wanted to switch sound from speaker to earpiece in android while I am using "https://crosswalk-project.org" web view to load a URL from where the user can calls to another user in the web view. for more simple : I just load a web URL to web view which supports web RTC. In android, the sound is coming from the speaker but I want to route it to an earpiece.
someone suggested me to use your plugin but I am confused as how to use it in android or server end.
I need you help in that , it will be appreciable thanks in advance.:)
I'm using audiotoggle on an ionic project.
It seems that switching to Speakerphone fails since I upgraded phone to IOS9, and I see no error msg in xcode console.
Has anyone successfully experienced the pugin on IOS9?
Plugin can't be downloaded using the path you provided.
Hi I test the plugin from the fork that got package.json
the AudioToggle is detected but it didn't work
I tried all the options and nothing change audio route.
How to make it works? Thank you
I am using this plugin and when it runs I get the following message:
Can not read property 'setAudioMode' of undefined.
I'm using ionic 3.
Can someone help me?
Thank you
Hi There,
I have added this plugin to my phonegap app. but the given code example didn't work properly on mobile app. it generates error of 'audiotoggle is undefined'.
did you have any working example or how you used that code in your app ? Please let me know if you can help me with this issue.
Thanks,
I'm using Audiotoogle on my Chat app that also allow picture sharing.
When I try to open the Camera with the camera plugin I get the error "Impossible to use camera during call"
It worked fine on many Android phone models on Android 4.4, until tried on my new Samsung J5 with Android Lollipop.
Removing Audiotoggle allows me to access the camera in the app, again, and reinstalling Audiotoggle makes the error reappear.
It is unclear if this limitation is model based, based on a version on Android or enforced by the vendor, but it seems quite frequent by googling the problem.
I couldn't locate how Android deduces that my app generates a "call" looking at permissions in manifest, and I'm out ideas.
I really need the speakerphone feature AND the camera feature, and I believe I'm not the only one. Please adivse :)
Do you have basic example that uses this plug-in? I cannot get it to work in my application. I have not had issues using other Cordova plugins in my project. I was able to install audiotoggle, but when I add AudioToggle.setAudioMode(AudioToggle.EARPIECE); it crashes my javascript code for any thing after that point on both Android and iOS clients (no error in console though).
Howdy,
I've been testing this plugin and it works great. However, there is one issue on Android.
The problem is that neither MODE_IN_COMMUNICATION
or STREAM_MUSIC
is the normal media mode. So after switching to one or the other, audio from other applications does not function correctly. We need to be able to switch back to the communication mode when the application pauses or ends: MODE_NORMAL
http://developer.android.com/reference/android/media/AudioManager.html#MODE_NORMAL
Will work on adding some methods to do that.
hi,
Thanks a lot for the plugin. I am a NOOB to java / cordova and I have some difficulty in getting this plugin to work. I use a mobile app development platform. I have other plugins working and here is the sample of a JS file / plugin that works
cordova.define("com.badrit.MacAddress", function(require, exports, module) {
/*
* MacAddress
* Implements the javascript access to the cordova plugin for retrieving the device mac address. Returns 0 if not running on Android
* @author Olivier Brand
*/
/**
* @return the mac address class instance
*/
var MacAddress = {
getMacAddress: function(successCallback, failureCallback){
cordova.exec(successCallback, failureCallback, 'MacAddressPlugin',
'getMacAddress', []);
}
};
cordova.addConstructor(function () {
if (!window.plugins) {
window.plugins = {};
}
window.plugins.MacAddress = MacAddress;
return window.plugins.MacAddress;
});
});
And here is the code in your plugin / JS file
var exec = require('cordova/exec');
exports.SPEAKER = 'speaker';
exports.EARPIECE = 'earpiece';
exports.NORMAL = 'normal';
exports.RINGTONE = 'ringtone';
exports.setAudioMode = function (mode) {
cordova.exec(null, null, 'AudioTogglePlugin', 'setAudioMode', [mode]);
};
Is it possible to change the JS in your plugin to suit my platform? If you could help in any way that'll be great. Mainly the part I couldn't understand was the exports / parameters below
exports.SPEAKER = 'speaker';
exports.EARPIECE = 'earpiece';
exports.NORMAL = 'normal';
exports.RINGTONE = 'ringtone';
Thanks once again,
M&M
Now that phonegap needs us to use npmjs based plugins instead of pgb, I am trying to find the same plugin in npmjs, but couldn't find it. Can you help me?
I'd like to know which audio output is used.
While my app is in background, during a call, I'd want to know if the user is using the the normale speaker or the earpiece.
I't would be great also listen for the event when the user toggle the audio in the native call display (outside my app)
Is it possible?
I use ionic,
Use the following instructions to install。
$ ionic cordova plugin add cordova-plugin-audiotoggle --save
It is working in android,It is not working in ios。
Can you show me a demo code on how to use this in ionic ?
Fetching plugin "com.dooble.audiotoggle" via npm
Fetching plugin "com.dooble.audiotoggle" via cordova plugins registry
Error: Failed to fetch plugin com.dooble.audiotoggle via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: connect ECONNREFUSED 50.17.177.14:80
This command:
cordova plugin add com.dooble.audiotoggle
gives the following error:
Error: Registry returned 404 for GET on https://registry.npmjs.org/com.dooble.audiotoggle
Thanx
Calling AudioToggle.setAudioMode(AudioToggle.SPEAKER);
should not disable the microphone on iOS devices.
I tried to use like cordova.plugins.audiotoggle.setAudioMode but its not working.
Hey,
I was able to successfully install and run this plugin in my Ionic 1 project. I am setting AudioToggle to only be the earpiece, but it isn't working. There are no errors associated with this.
I'm using this plugin in combination with cordova-media-plugin. I am playing audio files and do not want the sound to come out of the speaker, only the earpiece. The file is playing perfectly fine.
Is anybody experiencing this issue? If so, how did you resolve this?
I have been trying to use this plugin in my controllers but it has never worked. its keeps giving me
Error: AudioToggle is not defined
When I am using the audiotoggle to change from speaker to bluetooth in Angular wrapped in Cordova . I could speak to the speaker but is unable to speak to the bluetooth microphone .I imported it in my angular project.
if(Headset is not detected){
Audiotoggle--->speaker
}
else{
Audiotoggle-->Earpeice
}
Could you tell me if there is a solution ?
@lylepratt @alongubkin
Hy the plugin doesn't work in iOS 10 is it possible to update it?
There any way to mute the microphone with this plugin or otherwise?
Disregard.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.