From f7fb01b85dc7dc13e1b23f8d040c41f02ae8b125 Mon Sep 17 00:00:00 2001 From: Anatoliy Klymenko Date: Wed, 6 Dec 2017 16:22:58 -0800 Subject: [PATCH] Fix protection controller teardown --- app/js/streaming/protection/ProtectionController.js | 2 +- app/js/streaming/protection/ProtectionModel_01b.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/js/streaming/protection/ProtectionController.js b/app/js/streaming/protection/ProtectionController.js index 21e6fb0f0..b18f8b6d6 100644 --- a/app/js/streaming/protection/ProtectionController.js +++ b/app/js/streaming/protection/ProtectionController.js @@ -644,8 +644,8 @@ MediaPlayer.dependencies.ProtectionController = function() { this.keySystem = undefined; + this.protectionModel.teardown(); this.setMediaElement(null).then(function() { - self.protectionModel.teardown(); self.protectionModel = undefined; }); }, diff --git a/app/js/streaming/protection/ProtectionModel_01b.js b/app/js/streaming/protection/ProtectionModel_01b.js index 0a6c77dc3..32f6e742a 100644 --- a/app/js/streaming/protection/ProtectionModel_01b.js +++ b/app/js/streaming/protection/ProtectionModel_01b.js @@ -409,7 +409,10 @@ MediaPlayer.models.ProtectionModel_01b = function () { closeKeySession: function(sessionToken) { // Send our request to the CDM - videoElement[api.cancelKeyRequest](this.keySystem.systemString, sessionToken.sessionID); + try { + // We might get INVALID_STATE exception if there are no outstanding requests - just ignore it + videoElement[api.cancelKeyRequest](this.keySystem.systemString, sessionToken.sessionID); + } catch (e) {} }, setServerCertificate: function(/*serverCertificate*/) { /* Not supported */ },