Merge pull request #115 from voldyman/overlay

Made video muted by default and added overlay to ask the user to unmute
This commit is contained in:
Nick 2020-05-13 13:31:14 -04:00 committed by GitHub
commit d759a3d7ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 16 deletions

View File

@ -191,10 +191,28 @@ input[type=text] {
border-bottom-right-radius: 5px;
}
#videoElement {
#videoWrapper {
position: relative;
display: flex;
}
#videoOverlay {
height: 100%;
width: 100%;
position: absolute;
background-color: rgb(0, 0, 0, 0.75);
z-index: 3;
text-align: center;
vertical-align: middle;
display: flex;
justify-content: center;
align-items: center;
z-index: 2;
}
#videoElement {
z-index: 1;
position: relative;
top: 50%;
transform: translateY(-50%);
width: 100%;
}

BIN
static/img/mute-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -2,16 +2,25 @@
function initPlayer() {
if (flvjs.isSupported()) {
var videoElement = document.getElementById("videoElement");
var flvPlayer = flvjs.createPlayer({
type: "flv",
url: "/live"
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
if (!flvjs.isSupported()) {
console.warn('flvjs not supported');
return;
}
let videoElement = document.querySelector("#videoElement");
let flvPlayer = flvjs.createPlayer({
type: "flv",
url: "/live"
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
let overlay = document.querySelector('#videoOverlay');
overlay.onclick = () => {
overlay.style.display = 'none';
videoElement.muted = false;
};
}
window.addEventListener("load", initPlayer);

View File

@ -35,10 +35,15 @@
{{define "body"}}
{{if .Video}}
<video id="videoElement" controls autoplay x5-video-player-type="h5" x5-video-player-fullscreen="true" playsinline
webkit-playsinline>
Your browser is too old and doesn't support HTML5 video.
</video>
<div id="videoWrapper">
<div id="videoOverlay">
<img src="/static/img/mute-icon.png" />
</div>
<video id="videoElement" x5-video-player-type="h5" x5-video-player-fullscreen="true" playsinline webkit-playsinline
autoplay muted controls>
Your browser is too old and doesn't support HTML5 video.
</video>
</div>
{{end}}
{{if .Chat}}