Open ghost opened 7 years ago
You can redefine getUserMedia function:
/* Set a microphone device id from navigator.mediaDevices.enumerateDevices() to this variable */
var global_microphone_device_id;
/* Here is overwrite of getUserMedia.
Sipml5 calls this function on each call,
so you are able to choose microphone only before call started */
var stored_getUserMedia_function;
if (typeof SIPml == 'undefined') {
//SIPml is still not loaded and does not picked up this functions
if (navigator.mozGetUserMedia) {
stored_getUserMedia_function = navigator.mozGetUserMedia.bind(navigator);
navigator.mozGetUserMedia = my_getUserMedia;
} else if (navigator.webkitGetUserMedia) {
stored_getUserMedia_function = navigator.webkitGetUserMedia.bind(navigator);
navigator.webkitGetUserMedia = my_getUserMedia;
} else {
console.info("Unknown browser");
};
} else {
console.info('Looks like sipml5 is loaded');
stored_getUserMedia_function = navigator.getUserMedia.bind(navigator);
navigator.getUserMedia = my_getUserMedia;
};
function my_getUserMedia(constraints, onSuccessCallback, onErrorCallback) {
if (global_microphone_device_id) {
constraints['audio'] = {
"mandatory": {
"sourceId": global_microphone_device_id
}
};
};
return stored_getUserMedia_function(constraints, onSuccessCallback, onErrorCallback);
};
is this answer still valid?
Is there a way to change the default audio input device. I want the user to be able to select input device of his choice for sipml call.