Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
sfu
Commits
96e5030d
Commit
96e5030d
authored
Dec 05, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work around Safari's autoplay restrictions.
parent
e8c732c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
static/sfu.js
static/sfu.js
+20
-8
No files found.
static/sfu.js
View file @
96e5030d
...
...
@@ -764,6 +764,11 @@ async function setMaxVideoThroughput(c, bps) {
}
}
function
isSafari
()
{
let
ua
=
navigator
.
userAgent
.
toLowerCase
();
return
ua
.
indexOf
(
'
safari
'
)
>=
0
&&
ua
.
indexOf
(
'
chrome
'
)
<
0
;
}
/**
* @param {string} [id]
*/
...
...
@@ -833,7 +838,7 @@ async function addLocalMedia(id) {
setButtonsVisibility
();
}
let
safari
Warning
Done
=
false
;
let
safari
Screenshare
Done
=
false
;
async
function
addShareMedia
()
{
if
(
!
getUserPass
())
...
...
@@ -852,13 +857,11 @@ async function addShareMedia() {
return
;
}
if
(
!
safariWarningDone
)
{
let
ua
=
navigator
.
userAgent
.
toLowerCase
();
if
(
ua
.
indexOf
(
'
safari
'
)
>=
0
&&
ua
.
indexOf
(
'
chrome
'
)
<
0
)
{
if
(
!
safariScreenshareDone
)
{
if
(
isSafari
())
displayWarning
(
'
Screen sharing under Safari is experimental.
'
+
'
Please use a different browser if possible.
'
);
}
safariWarningDone
=
true
;
safariScreenshareDone
=
true
;
}
let
c
=
newUpStream
();
...
...
@@ -931,7 +934,7 @@ async function addFileMedia(file) {
delUpMedia
(
c
);
}
};
setMedia
(
c
,
true
,
false
,
video
);
await
setMedia
(
c
,
true
,
false
,
video
);
c
.
userdata
.
play
=
true
;
setButtonsVisibility
()
}
...
...
@@ -1026,7 +1029,7 @@ function muteLocalTracks(mute) {
* - the video element to add. If null, a new element with custom
* controls will be created.
*/
function
setMedia
(
c
,
isUp
,
mirror
,
video
)
{
async
function
setMedia
(
c
,
isUp
,
mirror
,
video
)
{
let
peersdiv
=
document
.
getElementById
(
'
peers
'
);
let
div
=
document
.
getElementById
(
'
peer-
'
+
c
.
id
);
...
...
@@ -1080,6 +1083,15 @@ function setMedia(c, isUp, mirror, video) {
showVideo
();
resizePeers
();
if
(
!
isUp
&&
isSafari
()
&&
!
findUpMedia
(
'
local
'
))
{
// 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
)
{
}
}
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment