I want to play a protected video using dash.js
. I’m using dash v2.0 and it's completely different from v1. the below code which work in v1 no longer works in v2.
$(function() {
var AXINOM_DEMO_WV_LS = "http://axpr-wv-fe.cloudapp.net:8080/LicensingService";
var context = new Dash.di.DashContext();
var player = new MediaPlayer(context);
player.startup();
player.attachView(document.querySelector('#videoPlayer'));
player.attachProtectionData({"com.widevine.alpha": new MediaPlayer.vo.protection.ProtectionData(AXINOM_DEMO_WV_LS)});
$('#playButton').click(function() {
var videoUrl = 'http://level3-cdn.axprod.net/demo/manifestprot.ism/.mpd';
player.attachSource(videoUrl);
});
});
I have tried to rewrite it again in v2
$(function() {
var AXINOM_DEMO_WV_LS = "http://axpr-wv-fe.cloudapp.net:8080/LicensingService";
var player = dashjs.MediaPlayer().create();
player.initialize(document.querySelector("#videoPlayer"),"", true);
player.attachProtectionData({"com.widevine.alpha": new ProtectionData(AXINOM_DEMO_WV_LS)});
$('#playButton').click(function() {
var videoUrl = 'http://level3-cdn.axprod.net/demo/manifestprot.ism/.mpd';
player.attachSource(videoUrl);
});
});
But it's not working. an error is being thrown.
Uncaught ReferenceError: ProtectionData is not defined
at HTMLDocument.<anonymous> (main.js:5)
I don't know how to correctly define this protection data since there is no tutorial on how to do it. kindly assist.
I was finally able to solve the problem. In dash.js version 2, this is the way protectionData is set.
var AXINOM_DEMO_WV_LS = "http://axpr-wv-fe.cloudapp.net:8080/LicensingService";
var drmKeySystem ="com.widevine.alpha";
var protData ={drmKeySystem:{serverURL: AXINOM_DEMO_WV_LS}};
var player = dashjs.MediaPlayer().create();
player.initialize(document.querySelector("#videoPlayer"),"", true);
player.setProtectionData(protData);