IntroductionHow to update an SDK?
Getting started on Web (Extended)Getting started on WebAPI examplesHow to implement Keyboard HotkeysHow to embed an iframeHow to implement a seamless transition between videos?How can I use video inside THEOplayer?How to work around browser cache with a new license?How to customise quality selection & labels (MP4)How to get frame-accurate currentTime display in the UI Control barHow to play an LCEVC source with THEOplayer
Android Unified
Getting started on Unified AndroidUnified Android Feature Integrations
Getting started on AndroidAndroid SDK customizationAndroid SDK product flavorsHow to couple the native MediaRouteButton to THEOplayerHow to enable -experimental- native rendering on AndroidHow to do offline Playback with AES-128 Encrypted Streams on Android
Getting started on iOSiOS SDK CustomizationMy app does not want to build for the app storeHow to bypass copy() not working in Safari consoleHow to couple the native GCKUICastButton to THEOplayeriOS SDK Touch-events (gestures)Building for iOS Simulator, but the linked and embedded framework THEOplayerSDK.framework was built for iOS + iOS SimulatorHow to implement custom local network access (LNA) interstitial dialog for Chromecast
Android TV
Getting started on Android TV
Getting started on tvOS
Getting started on ChromecastChromecast Application Customization
Getting Started on webOS
Getting started on TizenInstalling the Tizen developer toolsSetting up a Tizen device for debuggingDeploying a test app on a physical Tizen deviceDeploying a test app on a Tizen emulator
Getting Started on Roku
Fire tv
Getting started on Fire TV

How can I use <video> inside THEOplayer?

You may be asking this question if you come from THEOplayer 1.X and were availing yourself of the properties of <video> for your implementation. Similar questions are:

  • Why did you lose the HTML5 video tag in version 2.X and following?
  • Does THEOplayer work without <video>?

THEOplayer still uses the <video> element, but it is no longer to be included manually on the page, as all necessary elements are generated inside the player container, which you find on the page.

However, if you were using <video> or its attributes for something in particular in your implementation, this is still possible. Here follows an example: HTML page and script.

<!DOCTYPE html>
<html lang="en">
        <meta charset="UTF-8">
        <title>THEOplayer Web SDK: Getting Started</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" type="text/css" href='/path/to/ui.css'> <!-- adds THEOplayer CSS -->
        <div class="theoplayer-container video-js theoplayer-skin">
            <!-- this is your custom <video> element to be modified as wished. It is important that it is inside the div.theoplayer-container -->
            <video width="400" controls src="//cdn.theoplayer.com/video/star_wars_episode_vii-the_force_awakens_official_comic-con_2015_reel_(2015)/index.m3u8">
        <script type='text/javascript' src='/path/to/THEOplayer.js'></script> <!-- adds THEOplayer library -->
        <!-- COMMENT: this script is what makes it possible. Find its content below in the article. -->
        <script src="/path/to/THEO-HTMLvideotag.js"  data-librarylocation="/path/to/"></script>
            var element = document.querySelector('.theoplayer-container');
            var player = new THEOplayer.Player(element, {
                libraryLocation : '/path/to/your-theoplayer-folder/'
            // COMMENT: this part of the configuration can now be deleted or hidden, as the same data is extracted from the video element
            // player.source = {
            //     sources : [{
            //         src : '//cdn.theoplayer.com/video/star_wars_episode_vii-the_force_awakens_official_comic-con_2015_reel_(2015)/index.m3u8',
            //         type : 'application/x-mpegurl'
            //     }]
            // };

Here follows the javascript code that makes it possible to use a custom <video> element inside the THEOplayer container.

var videos = document.querySelectorAll('video');
var scripts = document.querySelectorAll('script');
var libraryLocation = "";
for (var i = 0; i < scripts.length; i++) {
    if (scripts[i].src.match(/THEO-HTMLvideotag.js/)) {
        libraryLocation = scripts[i].dataset.librarylocation;
var players = [];
for (var i = 0; i < videos.length; i++) {
    var video = videos[i];
    var config = {
        controls: video.controls,
        autoplay: video.autoplay,
    if(video.src) {config.src = video.src;}
    else {
        var sources = video.querySelectorAll('source');
       config.src = sources[0].src;
    var element = video.parentNode;
    var player = createTHEOplayerInstance(element, config);
    players[i] = player;
function createTHEOplayerInstance(element, config) {
    var ui = {};
    if (config.width || config.height) {
        ui.width = config.width || "";
        ui.height = config.height || "";
    } else {
        ui.fluid = true;
    var playerConfig = {
        "libraryLocation": libraryLocation,
        ui: ui
    var player = new THEOplayer.Player(element, playerConfig);
    player.autoplay = config.autoplay;
    player.src = config.src;
    player.loop = config.loop;
    player.muted = config.muted;
    player.poster = config.poster;
    player.preload = config.preload;
    return player;

Please note that:

  • the script must be called in the page after the call to the THEOplayer library
  • both calls are preferably located at the end of the body content
  • the value of the attribute "data-librarylocation" is the path to the folder where both scripts are located
  • the script makes it possible to use also the tag <source> inside <video>, but this functionality is for the time being very limited, namely: only the source.src of the first <source> tag is being read.
Make sure to follow us on GitHub!
Copyright © 2022. All Rights Reserved.
New York