Dash-Industry-Forum / dash.js

A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.
http://reference.dashif.org/dash.js/nightly/samples/dash-if-reference-player/index.html
Other
5.13k stars 1.68k forks source link

Dashjs player compatibility support #4496

Closed codestrap97a closed 4 months ago

codestrap97a commented 4 months ago
Environment

I am using clearkey encryption method to encrypt a sample clip for checking dashjs player functionality! I used Bento4 tool to dash and encrypt the clip with a key, everything is fine on Firefox desktop browser. the encrypted clip is sent to the browser and decrypted and played thoroughly without any issues. But on Chrome/Brave/Edge desktop and android browser devices, although the whole dash segments and mpd file is downloaded by browser but the clip is not played on such platforms/browsers!

The console error in chrome/ Brave browser:

[135][Stream] Error sending update() message! TypeError 

The client js code is shown below:

 function init() {
          const protData = {
                  "org.w3.clearkey": {
                          "clearkeys": {
                              "TcLE3lyyED7NgHNH6W0p6g" : "7SZugA/S7Yxok+CpHxnaWQ"
                          },
                          "priority": 0
                  }
          };
          var video,
              player,
              url = "https://dev.kavoshfarda.ir/output/stream.mpd";

          video = document.querySelector("video");
          player = dashjs.MediaPlayer().create();
          player.updateSettings({ 'debug': { 'logLevel': dashjs.Debug.LOG_LEVEL_DEBUG }});

          player.initialize(video, url, true);
          player.setProtectionData(protData);

      }
      function check() {
          if (location.protocol === 'http:' && location.hostname !== 'localhost') {
              var out = 'This page has been loaded under http. This might result in the EME APIs not being available to the player and any DRM-protected content will fail to play. ' +
                  'If you wish to test manifest URLs that require EME support, then <a href=\'https:' + window.location.href.substring(window.location.protocol.length) + '\'>reload this page under https</a>.'
              var div = document.getElementById('http-warning');
              div.innerHTML = out;
              div.style.display = ''
          }
      }
davemevans commented 4 months ago

At a guess I would say this is because your key is not base64url encoded as required by EME. Checking the browser code, it appears Firefox explicitly forgives this when parsing the key object, but Chromium is more strict, requiring base64url alphabet only.

Replace + with -, and / with _, and retry.

codestrap97a commented 4 months ago

At a guess I would say this is because your key is not base64url encoded as required by EME. Checking the browser code, it appears Firefox explicitly forgives this when parsing the key object, but Chromium is more strict, requiring base64url alphabet only.

Replace + with -, and / with _, and retry.

it works! I appreciate your assistance! you are right chromium uses strict base64 url!

dsilhavy commented 4 months ago

Thanks for your help @davemevans