move GUM to body.onload
This commit is contained in:
parent
54ea1da98e
commit
c6f7e192d0
51
app.js
51
app.js
|
@ -69,6 +69,24 @@ function init() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obtainAudioAndVideoPermissions(function (stream) {
|
||||||
|
var audioStream = new webkitMediaStream(stream);
|
||||||
|
var videoStream = new webkitMediaStream(stream);
|
||||||
|
var videoTracks = stream.getVideoTracks();
|
||||||
|
var audioTracks = stream.getAudioTracks();
|
||||||
|
for (var i = 0; i < videoTracks.length; i++) {
|
||||||
|
audioStream.removeTrack(videoTracks[i]);
|
||||||
|
}
|
||||||
|
VideoLayout.changeLocalAudio(audioStream);
|
||||||
|
startLocalRtpStatsCollector(audioStream);
|
||||||
|
|
||||||
|
for (i = 0; i < audioTracks.length; i++) {
|
||||||
|
videoStream.removeTrack(audioTracks[i]);
|
||||||
|
}
|
||||||
|
VideoLayout.changeLocalVideo(videoStream, true);
|
||||||
|
maybeDoJoin();
|
||||||
|
});
|
||||||
|
|
||||||
var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname;
|
var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname;
|
||||||
connect(jid);
|
connect(jid);
|
||||||
}
|
}
|
||||||
|
@ -100,29 +118,11 @@ function connect(jid, password) {
|
||||||
if (config.useStunTurn) {
|
if (config.useStunTurn) {
|
||||||
connection.jingle.getStunAndTurnCredentials();
|
connection.jingle.getStunAndTurnCredentials();
|
||||||
}
|
}
|
||||||
obtainAudioAndVideoPermissions(function (stream) {
|
|
||||||
audioStream = new webkitMediaStream(stream);
|
|
||||||
videoStream = new webkitMediaStream(stream);
|
|
||||||
var videoTracks = stream.getVideoTracks();
|
|
||||||
var audioTracks = stream.getAudioTracks();
|
|
||||||
for (var i = 0; i < videoTracks.length; i++) {
|
|
||||||
audioStream.removeTrack(videoTracks[i]);
|
|
||||||
}
|
|
||||||
audioStreamReady(audioStream);
|
|
||||||
VideoLayout.changeLocalAudio(audioStream);
|
|
||||||
startLocalRtpStatsCollector(audioStream);
|
|
||||||
|
|
||||||
for (i = 0; i < audioTracks.length; i++) {
|
|
||||||
videoStream.removeTrack(audioTracks[i]);
|
|
||||||
}
|
|
||||||
VideoLayout.changeLocalVideo(videoStream, true);
|
|
||||||
doJoin();
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('connect').disabled = true;
|
document.getElementById('connect').disabled = true;
|
||||||
|
|
||||||
if(password)
|
if(password)
|
||||||
authenticatedUser = true;
|
authenticatedUser = true;
|
||||||
|
maybeDoJoin();
|
||||||
} else if (status === Strophe.Status.CONNFAIL) {
|
} else if (status === Strophe.Status.CONNFAIL) {
|
||||||
if(msg === 'x-strophe-bad-non-anon-jid') {
|
if(msg === 'x-strophe-bad-non-anon-jid') {
|
||||||
anonymousConnectionFailed = true;
|
anonymousConnectionFailed = true;
|
||||||
|
@ -165,17 +165,14 @@ function obtainAudioAndVideoPermissions(callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function audioStreamReady(stream) {
|
function maybeDoJoin() {
|
||||||
|
if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
|
||||||
|
&& (connection.jingle.localAudio || connection.jingle.localVideo)) {
|
||||||
}
|
|
||||||
|
|
||||||
function videoStreamFailed(error) {
|
|
||||||
console.warn("Failed to obtain video stream - continue anyway", error);
|
|
||||||
|
|
||||||
doJoin();
|
doJoin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function doJoin() {
|
function doJoin() {
|
||||||
var roomnode = null;
|
var roomnode = null;
|
||||||
var path = window.location.pathname;
|
var path = window.location.pathname;
|
||||||
|
|
Loading…
Reference in New Issue