OptiView Live Streaming
Tip: open your browser's developer console and use the player and THEOplayer variables to interact with this demo.
| player.latency.currentLatency | — |
|---|
OptiView Live Streaming delivers real-time video at sub-second latency.
Set the source type to "theolive" and src to your channel or distribution ID.
player.source = {
sources: {
type: 'theolive',
src: 'ar5c53uzm3si4h4zgkzrju44h',
},
};
The readout above shows player.latency.currentLatency, the end-to-end latency in seconds,
updated on every timeupdate event.
See the TheoLiveSource
API reference for all available fields.
Code
demo.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>OptiView Live Streaming</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.
An OptiView Live Streaming source: 'src' is the channel or distribution ID.
-->
<theoplayer-default-ui
configuration='{"libraryLocation":"https://cdn.theoplayer.com/dash/theoplayer/","licenseUrl":"../../../../theoplayer-license.txt","mutedAutoplay":"all"}'
source='{"sources":{"type":"theolive","src":"ar5c53uzm3si4h4zgkzrju44h"}}'
></theoplayer-default-ui>
<script src="../utils.js"></script>
<script>
onPlayerReady((player) => {
// player.latency.currentLatency is only available during live playback.
player.addEventListener('timeupdate', () => {
sendToParent('latency', { latency: player.latency.currentLatency ?? null });
});
});
</script>
</body>
</html>