Skip to content

Commit 9599dab

Browse files
committed
samples dash-if-reference-player: store persistent session ids, and reuse them when reloading the streaml
1 parent 8caa553 commit 9599dab

File tree

1 file changed

+24
-0
lines changed
  • samples/dash-if-reference-player/app

1 file changed

+24
-0
lines changed

samples/dash-if-reference-player/app/main.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ app.controller('DashController', function ($scope, sources, contributors, dashif
201201
$scope.fastSwitchSelected = true;
202202
$scope.ABRStrategy = 'abrDynamic';
203203

204+
// Persistent license
205+
$scope.licenseSessionId = {};
206+
$scope.selectedKeySystem = null;
207+
204208
// Error management
205209
$scope.error = '';
206210
$scope.errorType = '';
@@ -294,6 +298,20 @@ app.controller('DashController', function ($scope, sources, contributors, dashif
294298
}
295299
}, $scope);
296300

301+
$scope.player.on(dashjs.MediaPlayer.events.KEY_SYSTEM_SELECTED, function (e) { /* jshint ignore:line */
302+
if (e.data) {
303+
$scope.selectedKeySystem = e.data.keySystem.systemString;
304+
}
305+
}, $scope);
306+
307+
$scope.player.on(dashjs.MediaPlayer.events.KEY_SESSION_CREATED, function (e) { /* jshint ignore:line */
308+
if (e.data) {
309+
var session = e.data;
310+
if (session.getSessionType() === 'persistent-license') {
311+
$scope.licenseSessionId[$scope.selectedItem.url] = session.getSessionID();
312+
}
313+
}
314+
}, $scope);
297315

298316
////////////////////////////////////////
299317
//
@@ -366,6 +384,12 @@ app.controller('DashController', function ($scope, sources, contributors, dashif
366384
protData = null;
367385
}
368386

387+
// Check if persistent license session ID is stored for current stream
388+
var sessionId = $scope.licenseSessionId[$scope.selectedItem.url];
389+
if (sessionId) {
390+
protData[$scope.selectedKeySystem].sessionId = sessionId;
391+
}
392+
369393
var bufferConfig = {
370394
liveDelay: $scope.defaultLiveDelay,
371395
stableBufferTime: $scope.defaultStableBufferDelay,

0 commit comments

Comments
 (0)