Create a basic player using TVSDK

Last update: 2023-10-02

Complete the following steps to create a basic player using the Browser TVSDK.

  1. Create a new directory in which you can download the compressed files for Browser TVSDK.

  2. Download Browser TVSDK from Zendesk, decompress the files, and place the frameworks folder in the new directory.

  3. Create a simple HTML boilerplate for the code with a div in it.

  4. Place this boilerplate in an HTML file in the directory you created in step 1.

    <!DOCTYPE html>
    <html lang="en">
          <div id="videoDiv" width="200" height="200">
         <div id="video-controls"></div>
  5. Add the Browser TVSDK libraries in the head section.

    <script src= "frameworks/player/dash.min.js"></script>
    <script src= "frameworks/player/primetimemain.min.js"></script>
    <script src= "frameworks/player/swfobject.js"></script>
    <script src= "frameworks/player/primetimeei.min.js"></script>
  6. For the body tag, add the onLoad section.

    <body onload="startVideo()">
  7. Start implementing the startVideo function.

  8. Add a script tag and create the startVideo function in the tag.

    This is supposed to be in the head section of the page.

     function startVideo(){
  9. Create the Adobe.MediaPlayer.

    var player = new AdobePSDK.MediaPlayer();
  10. Create the MediaPlayerView.


    This is where the div that you created earlier is used.

    var view = new AdobePSDK.MediaPlayerView(
    player.view = view;
  11. Add the player event listener.

    player.addEventListener(AdobePSDK.PSDKEventType.STATUS_CHANGED, onStatusChange);
  12. Implement the event handler and put this before the add event listener.

    var onStatusChange = function (event) {
     switch (event.status) {
      case AdobePSDK.MediaPlayerStatus.IDLE:
       console.log("Player Status: IDLE");
      case AdobePSDK.MediaPlayerStatus.INITIALIZING:
       console.log("Player Status: INITIALIZING");
      case AdobePSDK.MediaPlayerStatus.INITIALIZED:
       console.log("Player Status: INITIALIZED");
      case AdobePSDK.MediaPlayerStatus.PREPARING:
       console.log("Player Status: PREPARING");
      case AdobePSDK.MediaPlayerStatus.PREPARED:
       console.log("Player Status: PREPARED");
      case AdobePSDK.MediaPlayerStatus.PLAYING:
       console.log("Player Status: PLAYING");
       //update UI play/pause to show pause icon
      case AdobePSDK.MediaPlayerStatus.PAUSED:
       console.log("Player Status: PAUSED");
       //update UI play/pause to show play icon &
       //display pause icon over video
      case AdobePSDK.MediaPlayerStatus.SEEKING:
       console.log("Player Status: SEEKING");
      case AdobePSDK.MediaPlayerStatus.COMPLETE:
       console.log("Player Status: COMPLETE");
      case AdobePSDK.MediaPlayerStatus.RELEASED:
       console.log("Player Status: RELEASED");
      case AdobePSDK.MediaPlayerStatus.RELEASED:
       console.log("Player Status: ERROR");
  13. Create the MediaResource, which passes the M3U8 link (or mpd).

    var resourceUrl = "";
    var resourceType = AdobePSDK.MediaResourceType.HLS;
    var mediaResource = new AdobePSDK.MediaResource(resourceUrl, resourceType, null, false);
  14. Create an empty config and replace the resource.

    var config = new AdobePSDK.MediaPlayerItemConfig();
    player.replaceCurrentResource(mediaResource, config);
  15. When the player is in the INITIALIZED state, call prepareToPlay.

     player.prepareToPlay(); // <- add this line
  16. After the player is in the PREPARED state, call play.

    case PREPARED:;

On this page