1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 20:52:20 +00:00

On click, mute and demute player

This commit is contained in:
Alexandre Iooss 2020-10-18 18:52:41 +02:00
parent ac5fc7a33b
commit e1a0897cc4
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
2 changed files with 28 additions and 26 deletions

View File

@ -69,11 +69,6 @@ video {
} }
/* Hide chat toggler on small screen */ /* Hide chat toggler on small screen */
.control-chat {
display: none;
}
@media(min-width:1000px){
.control-chat { .control-chat {
display: inline; display: inline;
} }
}

View File

@ -74,25 +74,32 @@ startPeerConnection = () => {
} }
} }
// Register keyboard interactions // Register keyboard events
window.onkeydown = function (event) {
let viewer = document.getElementById("viewer") let viewer = document.getElementById("viewer")
// Toggle fullscreen mode window.onkeydown = (event) => {
if (event.key === "f") { switch (event.key) {
if (document.fullscreen) case 'f':
document.exitFullscreen().then() // F key put player in fullscreen
else if (document.fullscreenElement !== null) {
viewer.requestFullscreen().then() document.exitFullscreen()
} else {
viewer.requestFullscreen()
} }
// (Un)mute the stream break
else if (event.key === "m") { case 'm':
viewer.muted = !viewer.muted; case ' ':
} // M and space key mute player
// Pause the stream viewer.muted = !viewer.muted
else if (event.key === " ") { break
if (viewer.paused)
viewer.play()
else
viewer.pause()
} }
} }
// On click, mute and demute
viewer.addEventListener("play", (event) => {
event.preventDefault()
viewer.muted = !viewer.muted
})
viewer.addEventListener("pause", (event) => {
event.preventDefault()
viewer.muted = !viewer.muted
})