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

Register keyboard interactions to mute/pause/set fullscreen mode

This commit is contained in:
Yohann D'ANELLO 2020-10-18 11:32:57 +02:00
parent 9fc94cf0de
commit 1a0fcb9c44

View File

@ -73,3 +73,26 @@ startPeerConnection = () => {
}
}
}
// Register keyboard interactions
window.onkeydown = function (event) {
let viewer = document.getElementById("viewer")
// Toggle fullscreen mode
if (event.key === "f") {
if (document.fullscreen)
document.exitFullscreen().then()
else
viewer.requestFullscreen().then()
}
// (Un)mute the stream
else if (event.key === "m") {
viewer.muted = !viewer.muted;
}
// Pause the stream
else if (event.key === " ") {
if (viewer.paused)
viewer.play()
else
viewer.pause()
}
}