mplayer icon indicating copy to clipboard operation
mplayer copied to clipboard

setOptions({loop:0}) doesn't seem to work

Open gabrielstuff opened this issue 6 years ago β€’ 8 comments

Trying to play a file in loop does not seem to work.

gabrielstuff avatar Sep 06 '17 11:09 gabrielstuff

Have you set the option before or after .play()? Because it works fine, if I set it before playing. Probably does not apply after playing the track.

Riesi avatar Oct 03 '17 13:10 Riesi

I set it before. I actually tried, before and after with no luck. On OSX.

Thanks,

On Tue, Oct 3, 2017 at 3:06 PM Riesi [email protected] wrote:

Have you set the option before or after .play()? Because it works fine, if I set it before playing.

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/noodny/mplayer/issues/18#issuecomment-333835466, or mute the thread https://github.com/notifications/unsubscribe-auth/AARZaeE8lkdTNMO-mLU3cZfVCeroS-Jgks5sojFMgaJpZM4POOj3 .

-- πŸ‘Œ

gabrielstuff avatar Oct 04 '17 09:10 gabrielstuff

Look at my last solution! Not this one! Ok I don't know why it worked at first or if I got confused with other tests. Now it was also broken for me. Anyways... The problem it seems is that the varargs do not work. Due to this the length of the argument is always 0/undefined so the length check fails everytime.

My Solution (dirty fix):

Pass the arguments as an array:

  • .setOptions(['loop 0','speed 2'])//multiple args
  • .setOptions('loop 0')//single arg

And modify the line with 'set_property' in the setOptions function inside the index.js to:

  • this.player.cmd('set_property', value);//[key, value] old code

Beware that the changes might get overwritten by npm after an other installations. So copy the mplayer folder into the project root and use the following instead:

  • require('./mplayer'); //for local module

This solution is not really elegant compared to the one of noodny's, but it ain't broken for me. Maybe he could tell us why it does not work anymore. Could be a problem with lodash, but its just a bad guess. I also tried to set 'loop 0' after the start of the track and it works as long as it is still playing! I hope this works for you!

Riesi avatar Oct 04 '17 17:10 Riesi

I figured the problem out, but I am at university without my laptop today. So I cant test it in Node. I coded in an online Js editor with my phone. So if you want the fix how it should have been in the first place wait until my new post! (in approximately 7h) :grinning:

Riesi avatar Oct 05 '17 06:10 Riesi

:) Le jeu. 5 oct. 2017 Γ  08:56, Riesi [email protected] a Γ©crit :

I figured the problem out, but I am at university without my laptop today. So I cant test it in Node. I coded in an online Js editor with my phone. So if you want the fix how it should have been in the first place wait until my new post! (in approximately 7h) πŸ˜€

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/noodny/mplayer/issues/18#issuecomment-334375748, or mute the thread https://github.com/notifications/unsubscribe-auth/AARZaY8pLgMdzc8yf8i0iGEA1xa2Dw4Xks5spH2JgaJpZM4POOj3 .

-- πŸ‘Œ

gabrielstuff avatar Oct 05 '17 07:10 gabrielstuff

Solution

Replace the setOptions function with the following. Now the function should work as expected!

setOptions: function(options) {
        if(options && Object.keys(options).length) {
            Object.keys(options).forEach(function(key) {
                this.player.cmd('set_property', [key, options[key]]);
            }.bind(this));
       }
  }

Riesi avatar Oct 05 '17 12:10 Riesi

I want to set the volume before executing player.openPlaylist(). Is this the same issue we are talking about in this issue? The only way for setting the volume seems to be after invoking openPlaylist with a timeout of 1000ms. There must be another way?

hoetmaaiers avatar Oct 22 '17 17:10 hoetmaaiers

It should probably work with this fix, because every function that sets any option uses setOption. You can probably use openPlaylist(playlistfile, {volume:40}) to set the volume. A more patched version of the player can be found at Technici4n/mplayer. As long as noodny does not merge any pull requests.

Riesi avatar Nov 01 '17 16:11 Riesi