Keep the control bar visible
By default the control bar fades out after a few seconds of inactivity. These examples keep it visible at all times.
Open Video UI
Tip: open your browser's developer console and use the player and THEOplayer variables to interact with this demo.
Set user-idle-timeout to a negative value to disable idle detection, so the controls never fade out.
<theoplayer-default-ui user-idle-timeout="-1">...</theoplayer-default-ui>
Code
demo.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Keep control bar visible</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet" />
<style>
html,
body {
margin: 0;
padding: 0;
}
theoplayer-default-ui:not(:defined) {
display: inline-block;
box-sizing: border-box;
}
theoplayer-default-ui {
width: 100%;
aspect-ratio: 16 / 9;
font-family: 'Noto Sans', sans-serif;
background: #000;
}
</style>
<script src="https://cdn.theoplayer.com/dash/theoplayer/THEOplayer.js"></script>
<script nomodule src="https://unpkg.com/@theoplayer/web-ui@2/polyfills"></script>
<script async src="https://unpkg.com/@theoplayer/web-ui@2"></script>
</head>
<body>
<!--
libraryLocation: For demonstration purposes, we use the THEOplayer CDN.
For production use, host the library yourself and update this URL and the script above.
licenseUrl: Point this to your license file, or replace it with a license property.
user-idle-timeout="-1": a negative timeout disables the idle detection,
so the control bar never fades out.
-->
<theoplayer-default-ui
configuration='{"libraryLocation":"https://cdn.theoplayer.com/dash/theoplayer/","licenseUrl":"../../../../theoplayer-license.txt","mutedAutoplay":"all"}'
source='{"sources":{"src":"https://cdn.theoplayer.com/video/big_buck_bunny/big_buck_bunny.m3u8","type":"application/x-mpegurl"},"poster":"https://cdn.theoplayer.com/video/big_buck_bunny/poster.jpg","metadata":{"title":"Big Buck Bunny"}}'
user-idle-timeout="-1"
></theoplayer-default-ui>
<script src="../utils.js"></script>
</body>
</html>
Default UI
In the Default UI, override the fade-out transition with two CSS lines.
.theo-secondary-color.vjs-control-bar {
opacity: 1 !important;
visibility: visible !important;
}
Code
default-ui.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Keep control bar visible (Default UI)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.theoplayer.com/dash/theoplayer/ui.css" />
<script src="https://cdn.theoplayer.com/dash/theoplayer/THEOplayer.js"></script>
<style>
html,
body {
margin: 0;
padding: 0;
}
#player {
position: relative;
width: 100%;
}
/* Keep the control bar visible by overriding the fade-out transition. */
.theo-secondary-color.vjs-control-bar {
opacity: 1 !important;
visibility: visible !important;
}
</style>
</head>
<body>
<div id="player" class="video-js theoplayer-skin vjs-16-9"></div>
<script>
var player = new THEOplayer.Player(document.querySelector('#player'), {
libraryLocation: 'https://cdn.theoplayer.com/dash/theoplayer/',
licenseUrl: '../../../../theoplayer-license.txt',
mutedAutoplay: 'all',
});
player.source = {
sources: [{ src: 'https://cdn.theoplayer.com/video/big_buck_bunny/big_buck_bunny.m3u8', type: 'application/x-mpegurl' }],
poster: 'https://cdn.theoplayer.com/video/big_buck_bunny/poster.jpg',
metadata: { title: 'Big Buck Bunny' },
};
</script>
</body>
</html>