提交 ae05a19e authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-8401 refactor the sinkid function into verto lib

上级 fb8d4a2b
...@@ -2043,6 +2043,53 @@ ...@@ -2043,6 +2043,53 @@
return false; return false;
} }
// Attach audio output device to video element using device/sink ID.
function find_name(id) {
for (var i in $.verto.audioOutDevices) {
var source = $.verto.audioOutDevices[i];
if (source.id === id) {
return(source.label);
}
}
return id;
}
$.verto.dialog.prototype.setAudioPlaybackDevice = function(sinkId, callback, arg) {
var dialog = this;
var element = dialog.audioStream;
if (typeof element.sinkId !== 'undefined') {
var devname = find_name(sinkId);
console.info("Dialog: " + dialog.callID + " Setting speaker:", element, devname);
element.setSinkId(sinkId)
.then(function() {
console.log("Dialog: " + dialog.callID + ' Success, audio output device attached: ' + sinkId);
if (callback) {
callback(true, devname, arg);
}
})
.catch(function(error) {
var errorMessage = error;
if (error.name === 'SecurityError') {
errorMessage = "Dialog: " + dialog.callID + ' You need to use HTTPS for selecting audio output ' +
'device: ' + error;
}
if (callback) {
callback(false, null, arg);
}
console.error(errorMessage);
});
} else {
console.warn("Dialog: " + dialog.callID + ' Browser does not support output device selection.');
if (callback) {
callback(false, null, arg);
}
}
}
$.verto.dialog.prototype.setState = function(state) { $.verto.dialog.prototype.setState = function(state) {
var dialog = this; var dialog = this;
...@@ -2082,11 +2129,9 @@ ...@@ -2082,11 +2129,9 @@
console.info("Using Speaker: ", speaker); console.info("Using Speaker: ", speaker);
if (speaker && speaker !== "any") { if (speaker && speaker !== "any") {
var videoElement = dialog.audioStream;
setTimeout(function() { setTimeout(function() {
console.info("Setting speaker:", videoElement, speaker); dialog.setAudioPlaybackDevice(speaker);
attachSinkId(videoElement, speaker);}, 500); }, 500);
} }
break; break;
......
function attachSinkId(element, sinkId) {
if (typeof element.sinkId !== 'undefined') {
element.setSinkId(sinkId)
.then(function() {
console.log('Success, audio output device attached:', sinkId);
})
.catch(function(error) {
var errorMessage = error;
if (error.name === 'SecurityError') {
errorMessage = 'You need to use HTTPS for selecting audio output ' +
'device: ' + error;
}
console.error(errorMessage);
});
} else {
console.warn('Browser does not support output device selection.');
}
}
...@@ -96,7 +96,6 @@ ...@@ -96,7 +96,6 @@
<script type="text/javascript" src="js/3rd-party/getScreenId.js"></script> <script type="text/javascript" src="js/3rd-party/getScreenId.js"></script>
<script type="text/javascript" src="js/3rd-party/md5.min.js"></script> <script type="text/javascript" src="js/3rd-party/md5.min.js"></script>
<script type="text/javascript" src="js/3rd-party/volume-meter.js"></script> <script type="text/javascript" src="js/3rd-party/volume-meter.js"></script>
<script type="text/javascript" src="js/3rd-party/attachSinkId.js"></script>
<script type="text/javascript" src="src/vertoApp/vertoApp.module.js"></script> <script type="text/javascript" src="src/vertoApp/vertoApp.module.js"></script>
......
...@@ -36,7 +36,10 @@ ...@@ -36,7 +36,10 @@
}); });
$rootScope.$on('changedSpeaker', function(event, speakerId) { $rootScope.$on('changedSpeaker', function(event, speakerId) {
attachSinkId(myVideo, speakerId); // This should provide feedback
//setAudioPlaybackDevice(<id>[,<callback>[,<callback arg>]]);
// if callback is set it will be called as callback(<bool success/fail>, <device name>, <arg if you supplied it>)
verto.data.call.setAudioPlaybackDevice(speakerId);
}); });
/** /**
......
This diff was suppressed by a .gitattributes entry.
...@@ -234,33 +234,6 @@ function do_speed_test(fn) ...@@ -234,33 +234,6 @@ function do_speed_test(fn)
}); });
} }
// Attach audio output device to video element using device/sink ID.
function attachSinkId(element, sinkId) {
if (typeof element.sinkId !== 'undefined') {
element.setSinkId(sinkId)
.then(function() {
console.log('Success, audio output device attached: ' + sinkId);
})
.catch(function(error) {
var errorMessage = error;
if (error.name === 'SecurityError') {
errorMessage = 'You need to use HTTPS for selecting audio output ' +
'device: ' + error;
}
console.error(errorMessage);
// Jump back to first output device in the list as it's the default.
//audioOutputSelect.selectedIndex = 0;
});
} else {
console.warn('Browser does not support output device selection.');
}
}
function messageTextToJQ(body) { function messageTextToJQ(body) {
// Builds a jQuery collection from body text, linkifies http/https links, imageifies http/https links to images, and doesn't allow script injection // Builds a jQuery collection from body text, linkifies http/https links, imageifies http/https links to images, and doesn't allow script injection
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论