mirror of
https://github.com/jech/galene.git
synced 2024-11-25 01:55:57 +01:00
Open microphone early on Safari.
Safari forbids autoplay and omits host candidates unless the microphone is open.
This commit is contained in:
parent
0de0199742
commit
1afb3c85b0
1 changed files with 18 additions and 15 deletions
|
@ -275,6 +275,14 @@ function showVideo() {
|
||||||
scheduleReconsiderDownRate();
|
scheduleReconsiderDownRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSafari() {
|
||||||
|
let ua = navigator.userAgent.toLowerCase();
|
||||||
|
return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @type {MediaStream} */
|
||||||
|
let safariStream = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param{boolean} connected
|
* @param{boolean} connected
|
||||||
*/
|
*/
|
||||||
|
@ -289,6 +297,15 @@ function setConnected(connected) {
|
||||||
window.onresize = function(e) {
|
window.onresize = function(e) {
|
||||||
scheduleReconsiderDownRate();
|
scheduleReconsiderDownRate();
|
||||||
}
|
}
|
||||||
|
if(isSafari()) {
|
||||||
|
/* Safari doesn't allow autoplay and omits host candidates
|
||||||
|
* unless there is Open one and keep it around. */
|
||||||
|
if(!safariStream) {
|
||||||
|
navigator.mediaDevices.getUserMedia({audio: true}).then(s => {
|
||||||
|
safariStream = s;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
userbox.classList.add('invisible');
|
userbox.classList.add('invisible');
|
||||||
connectionbox.classList.remove('invisible');
|
connectionbox.classList.remove('invisible');
|
||||||
|
@ -1145,11 +1162,6 @@ function addFilters() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSafari() {
|
|
||||||
let ua = navigator.userAgent.toLowerCase();
|
|
||||||
return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const unlimitedRate = 1000000000;
|
const unlimitedRate = 1000000000;
|
||||||
const simulcastRate = 100000;
|
const simulcastRate = 100000;
|
||||||
const hqAudioRate = 128000;
|
const hqAudioRate = 128000;
|
||||||
|
@ -1444,7 +1456,7 @@ async function addShareMedia() {
|
||||||
if(!safariScreenshareDone) {
|
if(!safariScreenshareDone) {
|
||||||
if(isSafari()) {
|
if(isSafari()) {
|
||||||
let ok = confirm(
|
let ok = confirm(
|
||||||
'Screen sharing in Safari is badly broken. ' +
|
'Screen sharing in Safari is broken. ' +
|
||||||
'It will work at first, ' +
|
'It will work at first, ' +
|
||||||
'but then your video will randomly freeze. ' +
|
'but then your video will randomly freeze. ' +
|
||||||
'Are you sure that you wish to enable screensharing?'
|
'Are you sure that you wish to enable screensharing?'
|
||||||
|
@ -1758,15 +1770,6 @@ async function setMedia(c, mirror, video) {
|
||||||
|
|
||||||
showVideo();
|
showVideo();
|
||||||
resizePeers();
|
resizePeers();
|
||||||
|
|
||||||
if(!c.up && isSafari() && !findUpMedia('camera')) {
|
|
||||||
// Safari doesn't allow autoplay unless the user has granted media access
|
|
||||||
try {
|
|
||||||
let stream = await navigator.mediaDevices.getUserMedia({audio: true});
|
|
||||||
stream.getTracks().forEach(t => t.stop());
|
|
||||||
} catch(e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue