j-holub / Node-MPV

A NodeJs Module for MPV Player
https://www.npmjs.com/package/node-mpv
MIT License
116 stars 73 forks source link

[v2] mpv stops randomly on start #49

Closed vankasteelj closed 4 years ago

vankasteelj commented 5 years ago

When spawning a new player, sometimes (way to often, maybe 1/10) the load doesn't work.

mpv.start().then(() => {
   console.log('mpv started');
   return mpv.load('<my file>');
}).then(() => {
   console.log('file loaded');
});

The player does spawn, even the file is being read by MPV, yet the module fired a "stopped" event in between and the MPV binary is "free", your module doesnt have access to it.

The "stopped" event does occur after the console log "Connected to socket '\.\pipe\mpvserver'" though.

vankasteelj commented 5 years ago

When the above happens, the mpv.mpvPlayer.connected is false, but there is no exit code (it's set to default null). The exit code does update to 0 after a manual closing of the MPV spawned window

vankasteelj commented 5 years ago

So, it does seem that the issue is that mpv sends back (through ipcInterface) an "idle" event before playing the actual file. Causing the player to disconnect.

vankasteelj commented 5 years ago

Disabling the this.emit('stopped') in case of "idle" message from ipc (_events.js) corrects the issue. Now the file loads correctly everytime. Of course, it also disables the auto-close feature at the end of the file: the mpv player does close, but this module isnt made aware of it, logically because I presume mpv sends a "idle" message at that time. MMmmh

vankasteelj commented 5 years ago

Maybe this is an issue with how I use your module? I interpret the "stop" event as a "the file playback has stopped", when it is, as I see in your code, "the player idles". Anyway, I worked around it, but it still is wierd that it happens randomly.

AxelTerizaki commented 5 years ago

Which version of MPV are you using ? I know I've had some weird issues depending on which version I used.

vankasteelj commented 5 years ago

0.29 (31/07/2018)

j-holub commented 5 years ago

Thanks for letting me know. At the moment university keeps me really really busy that's why I haven't done much for this project in the past month. I'll try to have a look at it soon. Thanks for the very detailed feedback I think that will help a lot.

j-holub commented 4 years ago

I cannot reproduce this. I have done some changes to start() lately, which should make it more robust. Can you see if it still occurs on your case?

j-holub commented 4 years ago

Closing this for now as I cannot reproduce the error. Feel free to reopen it if the problem still prevails.