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
03087197
Commit
03087197
authored
Jun 09, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement local mute.
parent
94c42ea7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
2 deletions
+51
-2
static/sfu.css
static/sfu.css
+8
-0
static/sfu.html
static/sfu.html
+1
-0
static/sfu.js
static/sfu.js
+42
-2
No files found.
static/sfu.css
View file @
03087197
...
...
@@ -64,9 +64,17 @@ h1 {
#audioselect
{
width
:
8em
;
text-align-last
:
center
;
}
#mutebutton
{
width
:
6em
;
margin-right
:
0.4em
;
}
.muted
{
color
:
red
;
}
#sharebutton
,
#unsharebutton
{
width
:
8em
;
white-space
:
nowrap
;
...
...
static/sfu.html
View file @
03087197
...
...
@@ -44,6 +44,7 @@
<option>
default
</option>
<option>
off
</option>
</select>
<button
id=
"mutebutton"
>
Mute
</button>
</span>
<button
id=
"sharebutton"
class=
"invisible"
>
Share screen
</button>
...
...
static/sfu.js
View file @
03087197
...
...
@@ -170,16 +170,38 @@ function setButtonsVisibility() {
setVisibility
(
'
mediaoptions
'
,
permissions
.
present
);
}
document
.
getElementById
(
'
audioselect
'
).
onchange
=
function
(
e
)
{
let
localMute
=
false
;
function
toggleLocalMute
()
{
setLocalMute
(
!
localMute
);
}
function
setLocalMute
(
mute
)
{
localMute
=
mute
;
muteLocalTracks
(
localMute
);
let
button
=
document
.
getElementById
(
'
mutebutton
'
);
button
.
textContent
=
localMute
?
'
Unmute
'
:
'
Mute
'
;
if
(
localMute
)
button
.
classList
.
add
(
'
muted
'
);
else
button
.
classList
.
remove
(
'
muted
'
);
}
document
.
getElementById
(
'
videoselect
'
).
onchange
=
function
(
e
)
{
e
.
preventDefault
();
changePresentation
();
};
document
.
getElementById
(
'
vide
oselect
'
).
onchange
=
function
(
e
)
{
document
.
getElementById
(
'
audi
oselect
'
).
onchange
=
function
(
e
)
{
e
.
preventDefault
();
changePresentation
();
};
document
.
getElementById
(
'
mutebutton
'
).
onclick
=
function
(
e
)
{
e
.
preventDefault
();
toggleLocalMute
();
}
document
.
getElementById
(
'
sharebutton
'
).
onclick
=
function
(
e
)
{
e
.
preventDefault
();
addShareMedia
();
...
...
@@ -349,6 +371,8 @@ async function addLocalMedia() {
c
.
stream
=
stream
;
stream
.
getTracks
().
forEach
(
t
=>
{
c
.
labels
[
t
.
id
]
=
t
.
kind
if
(
t
.
kind
==
'
audio
'
&&
localMute
)
t
.
enabled
=
false
;
let
sender
=
c
.
pc
.
addTrack
(
t
,
stream
);
c
.
setInterval
(()
=>
{
updateStats
(
c
,
sender
);
...
...
@@ -428,6 +452,20 @@ function findUpMedia(kind) {
return
false
;
}
function
muteLocalTracks
(
mute
)
{
for
(
let
id
in
up
)
{
let
c
=
up
[
id
];
if
(
c
.
kind
===
'
local
'
)
{
let
stream
=
c
.
stream
;
stream
.
getTracks
().
forEach
(
t
=>
{
if
(
t
.
kind
===
'
audio
'
)
{
t
.
enabled
=
!
mute
;
}
});
}
}
}
function
setMedia
(
id
)
{
let
mine
=
true
;
let
c
=
up
[
id
];
...
...
@@ -1194,6 +1232,8 @@ function start() {
document
.
getElementById
(
'
title
'
).
textContent
=
title
;
}
setLocalMute
(
localMute
);
myid
=
randomid
();
getIceServers
().
catch
(
console
.
error
).
then
(
c
=>
{
...
...
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