Skip to main content
Skip table of contents

Creating the player

The player can be integrated by hosting the following lines of HTML on an HTTP server. This procedure is described on a step-by-step basis, to add all the code in one go, see the Completed code below. For more information about the code, see Code details.

  1. Unzip the opy-sdk-js-5.19.x-integration.zip / opy-sdk-js-5.19.x-integration-no-ui.zip and host the following files where they will be accessible to the HTML page you are creating.

    • opy-sdk-js-all-integration.jsopy-sdk-js-all-no-ui-integration.js

    • opy-sdk-js.css

  2. On your website or localhost environment, host the following snippet of HTML:

    XML
        <!DOCTYPE html>
        <html>
    	    <head>
    		    <meta charset="utf-8" />
    	    </head>
    
    	    <body>
    		    <div style="width: 80%;margin:auto"></div>
    	    </body>
        </html>
  3. Link the HTML to the SDK by inserting the script and CSS references into the <head>  section:

    XML
        <!DOCTYPE html>
        <html>
    	    <head>
    		    <meta charset="utf-8" />
    
    		    <script src="opy-sdk-js-all-integration.js"></script>
    		    <link rel="stylesheet" href="opy-sdk-js.css" />
    	    </head>
  4. Insert the <video> tag into the <body> of your HTML.

    XML
    	    <body>
    		    <div style="width: 80%;margin:auto">
    			    <video
    				    class="video-js vjs-default-skin vjs-16-9"
    				    id="videoPlayer"
    				    controls
    				    crossorigin="anonymous"
    			    ></video>
    		    </div>
    	    </body>
  5. Configure the player with the URL of the content to be played by adding the following JavaScript inside a <script></script> tag pair within the <body>:

    JS
    <script>
        document.addEventListener("DOMContentLoaded", () => {
    	    const playerInstance = otvplayer(
    		    "videoPlayer",
    		    {
    			    plugins: {
    				    otvtoolkit: {
    				    }
    			    }
    		    },
    		    () => {
    			    playerInstance.src({
    				    src:
    					   "https://d3bqrzf9w11pn3.cloudfront.net/basic_dash_bbb_clear/bbb_public.mpd",
    				    type: "application/dash+xml"
    			    });
    		    }
    	    );
        });
        </script>
  6. Navigate to the web page to test the player.

Completed code

Click here to see the completed code.
XML
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />

		 <script src="opy-sdk-js-all-integration.js"></script>
		<link rel="stylesheet" href="opy-sdk-js.css" />
		
	</head>
	<body>
		<div style="width: 80%;margin:auto">
			<video
				class="video-js vjs-default-skin vjs-16-9"
				id="videoPlayer"
				controls
				crossorigin="anonymous"
			></video>
		</div>
        <script>
			document.addEventListener("DOMContentLoaded", () => {
				const playerInstance = otvplayer(
					"videoPlayer",
					{
						plugins: {
							otvtoolkit: {
							}
						}
					},
					() => {
						playerInstance.src({
							src: "https://d3bqrzf9w11pn3.cloudfront.net/basic_dash_bbb_clear/bbb_public.mpd",
							type: "application/dash+xml"
						});
					}
				);
			});
		</script>
	</body>
</html>

Next step: You can now add player features.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.