From d50150eac547dd53b8034e1fa2aaa622ad35a712 Mon Sep 17 00:00:00 2001 From: Attila SATAN Date: Mon, 17 Jul 2017 12:59:32 +0300 Subject: [PATCH] Fix for uncaught error of destroy method patch for #174 In the presence of options `video: false` or `audio: false`, `destroy()` method of player instance throws an error as ```js Uncaught TypeError: Cannot read property 'destroy' of undefined at Player.destroy (jsmpeg.min.js:formatted:264) ``` --- src/player.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/player.js b/src/player.js index fa9a33e6..23a4e0b9 100644 --- a/src/player.js +++ b/src/player.js @@ -113,8 +113,10 @@ Player.prototype.stop = function(ev) { Player.prototype.destroy = function() { this.pause(); this.source.destroy(); - this.renderer.destroy(); - this.audioOut.destroy(); + if(this.renderer) + this.renderer.destroy(); + if(this.audioOut) + this.audioOut.destroy(); }; Player.prototype.seek = function(time) {