1
I need to get the audio stream played on the user’s phone/speakers and I’m finding a problem when it comes to getting the stream of the selected device. In short it is as follows: The phone ends up having the same microphone id 'Default' and the return of 'Navigator.mediaDevices.getUserMedia' even sending the device ends up becoming the microphone return.
this.start = function () {
return navigator.mediaDevices.getUserMedia({
audio: true
})
.then(function (objStream) {
navigator.mediaDevices.enumerateDevices().then(function (objDevices) {
var objAudio = objDevices.find(function (objDevice) {
return objDevice.kind == "audiooutput";
});
objStream.getTracks().forEach(function (objMidiaAudio) {
objMidiaAudio.stop();
});
if (objAudio) {
return navigator.mediaDevices.getUserMedia({
audio: objAudio
});
}
return navigator.mediaDevices.getUserMedia({
audio: true
});
})
.then(function (objStream) {
new Promise(function () {
var audio = objStream.getAudioTracks()[0];
This would be the code snippet where I’m having trouble, the objAudio variable, had the phone, but when I return to the 'then' the objStream has the microphone. Any suggestions on how to get around this problem?