<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<style>
body, html {
    width: 100%;
    height: 100%;
    margin: 0;
}

.container {
    width: 640px;
    height: 480px;
    position: relative;
    border: 1px solid red;
}

video {
    width: 100%;
    height: 100%;
}
</style>
</head>
<body>
    <div class="container">
        <video muted loop></video>
    </div>
</body>
<script>
var container = document.querySelector(".container");
var video = document.querySelector("video");

async function loadSource(source)
{
    return new Promise(resolve => {
        video.addEventListener("load", resolve, { once: true });
        video.src = source;
    });
}

async function waitForVideoFrame()
{
    return new Promise(resolve => {
        video.requestVideoFrameCallback((timestamp, metadata) => {
            resolve(timestamp);
        });
    });
}

function performWithUserGestureIfPossible(callback)
{
    if (window.internals)
        internals.withUserGesture(callback);
    else
        callback();
}

function enterFullscreen()
{
    if (document.webkitIsFullScreen)
        return false;

    performWithUserGestureIfPossible(() => {
        container.webkitRequestFullscreen({ navigationUI: "hide" });
        video.play();
    });
    return true;
}

function exitFullscreen()
{
    if (!document.webkitIsFullScreen)
        return false;

    performWithUserGestureIfPossible(() => {
        document.webkitExitFullscreen();
        video.pause();
    });
    return true;
}
</script>
</html>
