Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
},
Expand Down
17 changes: 11 additions & 6 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This or check seems completly unnesesary because the checks are repeated for each item below

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Do you want me to remove it ?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove it but there still needs to be a check for calling the setStatus so it isn't called when nothing is changed

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) {
Expand Down