From bdf8990a892ab0475813dc4a2ea5b38a3ca48b3d Mon Sep 17 00:00:00 2001 From: Technici4n Date: Fri, 5 May 2017 00:15:22 +0200 Subject: [PATCH 1/2] Fix: add duration to status for audio files --- lib/player.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/player.js b/lib/player.js index d1658b7..a129107 100644 --- a/lib/player.js +++ b/lib/player.js @@ -131,12 +131,17 @@ Player.prototype = _.extend({ this.emit('timechange', time) } - if(data.indexOf('ANS_LENGTH') !== -1 && data.indexOf('ANS_VO_FULLSCREEN') !== -1 && data.indexOf('ANS_SUB_VISIBILITY') !== -1) { - this.setStatus({ - duration: parseFloat(data.match(/ANS_LENGTH=([0-9\.]*)/)[1]), - fullscreen: (parseInt(data.match(/ANS_VO_FULLSCREEN=([01])/)[1]) === 1), - subtitles: (parseInt(data.match(/ANS_SUB_VISIBILITY=([01])/)[1]) === 1) - }); + if(data.indexOf('ANS_LENGTH') !== -1 || data.indexOf('ANS_VO_FULLSCREEN') !== -1 || data.indexOf('ANS_SUB_VISIBILITY') !== -1) { + var status = {}; + + if(data.indexOf('ANS_LENGTH') !== -1) + status.duration = parseFloat(data.match(/ANS_LENGTH=([0-9\.]*)/)[1]); + if(data.indexOf('ANS_VO_FULLSCREEN') !== -1) + status.fullscreen = (parseInt(data.match(/ANS_VO_FULLSCREEN=([01])/)[1]) === 1); + if(data.indexOf('ANS_SUB_VISIBILITY') !== -1) + status.subtitles = (parseInt(data.match(/ANS_SUB_VISIBILITY=([01])/)[1]) === 1); + + this.setStatus(status); } }, onError: function(error) { From 5f3cc184609f4959a61f45b0f05a7528c9bb066c Mon Sep 17 00:00:00 2001 From: Riesi Date: Thu, 5 Oct 2017 14:45:06 +0200 Subject: [PATCH 2/2] Fixed Maps for setOption Varpars as maps dont have a length value, but you can get the keys and work with them. --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 7c76be9..a523d61 100644 --- a/index.js +++ b/index.js @@ -77,9 +77,9 @@ var MPlayer = function(options) { MPlayer.prototype = _.extend({ setOptions: function(options) { - if(options && options.length) { - options.forEach(function(value, key) { - this.player.cmd('set_property', [key, value]); + if(options && Object.keys(options).length) { + Object.keys(options).forEach(function(key) { + this.player.cmd('set_property', [key, options[key]]); }.bind(this)); } },