Dash.js: Problem with MediaKeys on Android 4.4.2

Created on 25 Oct 2016  路  8Comments  路  Source: Dash-Industry-Forum/dash.js

Environment

Steps to reproduce
  1. Please provide clear steps to reproduce your problem
    This is my setup for loading an .mpd file on an Ionic controller.js:
  var loadDashjsVideo = function () {
    customDataWv = {
      "Conax-Custom-Data": cxWidevine.getCxCustomDataForWidevine($scope.loadedContent.token)
    };
    protectionData = {
      "com.widevine.alpha": {
        serverURL: widevineLicenseServerUrl,
        httpRequestHeaders: customDataWv,
        clearkeys: null
      }
    };
    if (!player) {
      player = dashjs.MediaPlayer().create();
    }
    player.setProtectionData(protectionData);
    player.initialize(video, null, false);
    player.attachSource($scope.loadedContent.link);
    player.on(dashjs.MediaPlayer.events['CAN_PLAY'], function() {
      player.play();
    });
  }

This works perfectly fine on Android 5, 6 and 7, tried it on a number of devices. However, it's not working on Android 4.4.2 (tried it on a tablet and a phone).

Observed behaviour

I'm running the exact same code on these different versions of Android and on 4.4.2 is where the problem occurs. What i can tell from the console log (included below) is that there's a problem when initializing the MediaKeys (which i don't fully understand what they are) and the CAN_PLAY event never gets triggered.

Console output

On Android 4.4.2

[78] EME detected on this user agent! (ProtectionModel_21Jan2015) 
dash.all.debug.js:2783 [96] [dash.js 2.3.0] MediaPlayer has been initialized 
dash.all.debug.js:2783 [104] Playback Initialized 
dash.all.debug.js:2783 [2077] Parsing complete: ( xml2json: 1.19e+3ms, objectiron: 280ms, total: 1.47s) 
dash.all.debug.js:2783 [2080] Manifest has been refreshed at Tue Oct 25 2016 13:01:36 GMT-0300 (ART)[1477411296.765]  
dash.all.debug.js:2783 [2086] SegmentTimeline detected using calculated Live Edge Time 
dash.all.debug.js:2783 [2105] MediaSource attached to element.  Waiting on open... 
dash.all.debug.js:2783 [2190] MediaSource is open! 
dash.all.debug.js:2783 [2192] Duration successfully set to: 4945.66675 
dash.all.debug.js:2783 [2197] Added 0 inline events 
dash.all.debug.js:2783 [2199] video codec: video/mp4;codecs="avc1.4D401E" 
dash.all.debug.js:2783 [2285] Schedule controller stopping for video 
dash.all.debug.js:2783 [2289] Last saved bitrate for video was 2328 
dash.all.debug.js:2783 [2312] audio codec: audio/mp4;codecs="mp4a.40.2" 
dash.all.debug.js:2783 [2401] Schedule controller stopping for audio 
dash.all.debug.js:2783 [2406] No text data. 
dash.all.debug.js:2783 [2407] No fragmentedText data. 
dash.all.debug.js:2783 [2409] No embeddedText data. 
dash.all.debug.js:2783 [2410] No muxed data. 
dash.all.debug.js:2783 [2415] Start Event Controller 
dash.all.debug.js:2783 [2422] Schedule controller starting for video 
dash.all.debug.js:2783 [2430] Schedule controller starting for audio 
dash.all.debug.js:2783 [2617] Init fragment finished loading saving to audio's init cache 
dash.all.debug.js:2783 [2627] Init fragment finished loading saving to video's init cache 
dash.all.debug.js:2783 [2638] DRM: onNeedKey 
dash.all.debug.js:2783 [2640] DRM: initData: 戮pssh職冒y聵@B聠芦聮忙[脿聢_聲聻聻聰<WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"><DATA><PROTECTINFO><KEYLEN>16</KEYLEN><ALGID>AESCTR</ALGID></PROTECTINFO><KID>Zxiu0jUd+0yXoi+t0P/Nlg==</KID><CHECKSUM>EenmhJsAOoE=</CHECKSUM><LA_URL>http://lsprnsmc2.boldmss.com/cxplayready/rightsmanager.asmx</LA_URL></DATA></WRMHEADER>apssh铆茂聥漏y脰J脦拢脠'脺脮!铆A脪庐g5L没聴垄/颅脨每脥聳Conax"$d2ae1867-1d35-4cfb-97a2-2fadd0ffcd96 
dash.all.debug.js:28563 It is recommended that a robustness level be specified. Not specifying the robustness level could result in unexpected behavior in the future, potentially including failure to play.
dash.all.debug.js:2783 [6441] DRM: onNeedKey 
dash.all.debug.js:2783 [6443] DRM: initData: 戮pssh職冒y聵@B聠芦聮忙[脿聢_聲聻聻聰<WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"><DATA><PROTECTINFO><KEYLEN>16</KEYLEN><ALGID>AESCTR</ALGID></PROTECTINFO><KID>Zxiu0jUd+0yXoi+t0P/Nlg==</KID><CHECKSUM>EenmhJsAOoE=</CHECKSUM><LA_URL>http://lsprnsmc2.boldmss.com/cxplayready/rightsmanager.asmx</LA_URL></DATA></WRMHEADER>apssh铆茂聥漏y脰J脦拢脠'脺脮!铆A脪庐g5L没聴垄/颅脨每脥聳Conax"$d2ae1867-1d35-4cfb-97a2-2fadd0ffcd96 
dash.all.debug.js:2783 [7190] DRM: KeySystem Access Granted (com.widevine.alpha)!  Selecting key system... 
dash.all.debug.js:2783 [7197] Getting the request for video time : 0 
dash.all.debug.js:2783 [7200] SegmentTimeline: 0 / 4945.66675 
dash.all.debug.js:2783 [7215] Getting the request for audio time : 0 
dash.all.debug.js:2783 [7219] SegmentTimeline: 0 / 4945.66675 
dash.all.debug.js:2783 [8058] DRM: Error selecting key system! -- Error selecting keys system (com.widevine.alpha)! Could not create MediaKeys -- TODO 
dash.all.debug.js:2783 [8077] Schedule controller stopping for video 
dash.all.debug.js:2783 [8086] Schedule controller stopping for audio 

On Android 7:

[42] EME detected on this user agent! (ProtectionModel_21Jan2015) 
dash.all.debug.js:2783 [47] [dash.js 2.3.0] MediaPlayer has been initialized 
dash.all.debug.js:2783 [56] Playback Initialized 
dash.all.debug.js:2783 [7199] Buffered Range for type: audio : 0  -  30.040083 
dash.all.debug.js:2783 [1090] Parsing complete: ( xml2json: 581ms, objectiron: 150ms, total: 0.731s) 
dash.all.debug.js:2783 [1091] Manifest has been refreshed at Tue Oct 25 2016 13:24:56 GMT-0300 (UYT)[1477412696.161]  
dash.all.debug.js:2783 [1093] SegmentTimeline detected using calculated Live Edge Time 
dash.all.debug.js:2783 [1098] MediaSource attached to element.  Waiting on open... 
dash.all.debug.js:2783 [1169] MediaSource is open! 
dash.all.debug.js:2783 [1172] Duration successfully set to: 4945.66675 
dash.all.debug.js:2783 [1174] Added 0 inline events 
dash.all.debug.js:2783 [1176] video codec: video/mp4;codecs="avc1.4D401E" 
dash.all.debug.js:2783 [1199] Schedule controller stopping for video 
dash.all.debug.js:2783 [1202] Last saved bitrate for video was 2328 
dash.all.debug.js:2783 [1223] audio codec: audio/mp4;codecs="mp4a.40.2" 
dash.all.debug.js:2783 [1293] Schedule controller stopping for audio 
dash.all.debug.js:2783 [1297] No text data. 
dash.all.debug.js:2783 [1298] No fragmentedText data. 
dash.all.debug.js:2783 [1299] No embeddedText data. 
dash.all.debug.js:2783 [1300] No muxed data. 
dash.all.debug.js:2783 [1303] Start Event Controller 
dash.all.debug.js:2783 [1306] Schedule controller starting for video 
dash.all.debug.js:2783 [1314] Schedule controller starting for audio 
dash.all.debug.js:2783 [1523] Init fragment finished loading saving to video's init cache 
dash.all.debug.js:2783 [1533] Init fragment finished loading saving to audio's init cache 
dash.all.debug.js:2783 [1538] DRM: onNeedKey 
dash.all.debug.js:2783 [1540] DRM: initData: 戮pssh職冒y聵@B聠芦聮忙[脿聢_聲聻聻聰<WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"><DATA><PROTECTINFO><KEYLEN>16</KEYLEN><ALGID>AESCTR</ALGID></PROTECTINFO><KID>Zxiu0jUd+0yXoi+t0P/Nlg==</KID><CHECKSUM>EenmhJsAOoE=</CHECKSUM><LA_URL>http://lsprnsmc2.boldmss.com/cxplayready/rightsmanager.asmx</LA_URL></DATA></WRMHEADER>apssh铆茂聥漏y脰J脦拢脠'脺脮!铆A脪庐g5L没聴垄/颅脨每脥聳Conax"$d2ae1867-1d35-4cfb-97a2-2fadd0ffcd96 
dash.all.debug.js:28563 It is recommended that a robustness level be specified. Not specifying the robustness level could result in unexpected behavior in the future, potentially including failure to play.
dash.all.debug.js:2783 [1546] Getting the request for video time : 0 
dash.all.debug.js:2783 [1548] SegmentTimeline: 0 / 4945.66675 
dash.all.debug.js:2783 [1560] DRM: onNeedKey 
dash.all.debug.js:2783 [1565] DRM: initData: 戮pssh職冒y聵@B聠芦聮忙[脿聢_聲聻聻聰<WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"><DATA><PROTECTINFO><KEYLEN>16</KEYLEN><ALGID>AESCTR</ALGID></PROTECTINFO><KID>Zxiu0jUd+0yXoi+t0P/Nlg==</KID><CHECKSUM>EenmhJsAOoE=</CHECKSUM><LA_URL>http://lsprnsmc2.boldmss.com/cxplayready/rightsmanager.asmx</LA_URL></DATA></WRMHEADER>apssh铆茂聥漏y脰J脦拢脠'脺脮!铆A脪庐g5L没聴垄/颅脨每脥聳Conax"$d2ae1867-1d35-4cfb-97a2-2fadd0ffcd96 
dash.all.debug.js:2783 [1597] DRM: KeySystem Access Granted (com.widevine.alpha)!  Selecting key system... 
dash.all.debug.js:2783 [1629] Getting the request for audio time : 0 
dash.all.debug.js:2783 [1639] SegmentTimeline: 0 / 4945.66675 
dash.all.debug.js:2783 [1669] DRM: Ignoring initData because we have already seen it! 
dash.all.debug.js:2783 [1685] Native video element event: loadedmetadata 
dash.all.debug.js:2783 [1741] DRM: Session created.  SessionID = sid16 
dash.all.debug.js:2783 [1745] Native video element event: play 
dash.all.debug.js:2783 [1748] Native video element event: playing 
dash.all.debug.js:2783 [1752] DRM: onKeyMessage 
dash.all.debug.js:2783 [1903] DRM: onKeyMessage 
dash.all.debug.js:2783 [2044] Buffered Range for type: audio : 0  -  5.016062 
dash.all.debug.js:2783 [2046] Got enough buffer to start. 
dash.all.debug.js:2783 [3004] Buffered Range for type: video : 0  -  5.005 
dash.all.debug.js:2783 [3007] Got enough buffer to start. 
dash.all.debug.js:2783 [3014] ThroughputRule requesting switch to index:  6 type:  video  Priority:  Default Average throughput 4738 kbps 
dash.all.debug.js:2783 [3318] Init fragment finished loading saving to video's init cache 
dash.all.debug.js:2783 [3321] Buffered Range for type: video : 0  -  5.005 
dash.all.debug.js:2783 [3322] DRM: onNeedKey 
dash.all.debug.js:2783 [3323] DRM: initData: 戮pssh職冒y聵@B聠芦聮忙[脿聢_聲聻聻聰<WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"><DATA><PROTECTINFO><KEYLEN>16</KEYLEN><ALGID>AESCTR</ALGID></PROTECTINFO><KID>Zxiu0jUd+0yXoi+t0P/Nlg==</KID><CHECKSUM>EenmhJsAOoE=</CHECKSUM><LA_URL>http://lsprnsmc2.boldmss.com/cxplayready/rightsmanager.asmx</LA_URL></DATA></WRMHEADER>apssh铆茂聥漏y脰J脦拢脠'脺脮!铆A脪庐g5L没聴垄/颅脨每脥聳Conax"$d2ae1867-1d35-4cfb-97a2-2fadd0ffcd96 
dash.all.debug.js:28563 It is recommended that a robustness level be specified. Not specifying the robustness level could result in unexpected behavior in the future, potentially including failure to play.
dash.all.debug.js:2783 [3328] Getting the request for video time : 5.005 
dash.all.debug.js:2783 [3329] SegmentTimeline: 0 / 4945.66675 
dash.all.debug.js:2783 [3330] Getting the next request at index: 1 
dash.all.debug.js:2783 [3330] SegmentTimeline: 5.005 / 4945.66675 
dash.all.debug.js:2783 [3367] DRM: KeySystem Access Granted 
dash.all.debug.js:2783 [3368] DRM: Ignoring initData because we have already seen it! 
dash.all.debug.js:2783 [4053] Getting the request for audio time : 5.0160833333333334 
Awaiting Feedback stale

Most helpful comment

We will be very grateful if someone could give us feedback with that problem! We need to play widevine on android 4.4.2, and we cannot get the solution!

All 8 comments

Maybe on these old devices there is implemented a different version of the EME spec. You can change the used EME version in Protection.js function getProtectionModel

I checked and both devices are executing the same code in getProtectionModel:

    function getProtectionModel(config) {

        var log = config.log;
        var eventBus = config.eventBus;
        var videoElement = config.videoModel.getElement();

        if (videoElement.onencrypted !== undefined && videoElement.mediaKeys !== undefined && navigator.requestMediaKeySystemAccess !== undefined && typeof navigator.requestMediaKeySystemAccess === 'function') {

            log('EME detected on this user agent! (ProtectionModel_21Jan2015)');
            return (0, _modelsProtectionModel_21Jan20152['default'])(context).create({ log: log, eventBus: eventBus });
        } else if (getAPI(videoElement, APIS_ProtectionModel_3Feb2014)) {

            log('EME detected on this user agent! (ProtectionModel_3Feb2014)');
            return (0, _modelsProtectionModel_3Feb20142['default'])(context).create({ log: log, eventBus: eventBus, api: getAPI(videoElement, APIS_ProtectionModel_3Feb2014) });
        } else if (getAPI(videoElement, APIS_ProtectionModel_01b)) {

            log('EME detected on this user agent! (ProtectionModel_01b)');
            return (0, _modelsProtectionModel_01b2['default'])(context).create({ log: log, eventBus: eventBus, api: getAPI(videoElement, APIS_ProtectionModel_01b) });
        } else {

            log('No supported version of EME detected on this user agent! - Attempts to play encrypted content will fail!');
            return null;
        }
    }

Both go through the very first 'if' statement, so i guess this isn't the problem?

yes I know that on both devices the same protection model is used. What I mean is change the protection model only for the Android 4.4 device. There could be a wrong auto detection.

Ok i see, sorry, i didn't quite get that.
I changed it so that the Android 4.4 device would use the protection data on the second 'if' statement, the

DRM: Error selecting key system! -- Error selecting keys system (com.widevine.alpha)! Could not create MediaKeys -- TODO 

error is gone but the CAN_PLAY event never gets triggered. Same thing happens on higher Android versions when using a protection data different from the first one.

With the 3rd protection data option i get

dash.all.debug.js:28067 Uncaught TypeError: Cannot read property 'keyerror' of null

on all devices.

We will be very grateful if someone could give us feedback with that problem! We need to play widevine on android 4.4.2, and we cannot get the solution!

@fabirydel @djmaxisauce Is this still an issue or can we close this ticket?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because no further activity occurred. If you think this issue is still relevant please reopen it. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattlohkamp picture mattlohkamp  路  4Comments

bbert picture bbert  路  5Comments

redd29 picture redd29  路  4Comments

sandersaares picture sandersaares  路  5Comments

fabienvallee picture fabienvallee  路  3Comments