Closed gabrielstuff closed 4 years ago
Same type of disconnect / reconnect appears on Debian and OSX
Hey there,
yes if you don't specify the socket, it takes the default socket /tmp/node-mpv.sock
, that is expected behavior to be honest.
And if you're using different sockets it is still random you say? That is weird to be honest, I'll have to look into that.
As for the disconnect/reconnect thing, yes it's annyoing and it's fixed in Version 2. Due to university and job I didn't have too much time to work on it lately, but I wanna continue develop it further soon. I already had a hand full of people using it and telling me it's way better and works great. Just remember it's subject to change if you use it.
I didn't think about using more than 1 mpv instance at the time because I can't imagine a reason to do so, but I'll see what I can do about it.
First thing would be figuring out why it works randomly with more than 1 instance and second would be, that if a first instance is already running maybe use a different socket, such that you can spawn multiple instances without specifying a socket explicitly.
I've been experimenting with this because the karaoke app I made can be used sometimes without the karaoke operator able to see the screen (screen is behind him, things like that) so I've setup a way to have a "monitor" window.
With the latest version of node-mpv-2, working with promises allowed me to spawn a second mpv instance with a few different options (another socket path, and with muted sound). I send to this second instance the exact same commands I send to the first one.
Since I don't need to read events from the second instance, this makes things easier.
If you want your two instances to load the same files at the same time, you can use Promise.all to make sure they're both executed together and wait before both are finished before adding subtitles or other commands.
I haven't seen any random behavior when using two different sockets.
V2 fixed it. See there https://github.com/00SteinsGate00/Node-MPV/tree/Node-MPV-2 to read about V2.
I just wrote few new apps that works great with the V2 version.
Thanks a lot
It looks like playing with multiple instance of mpv does not work well.
This simple example shows that connection to socket fails multiple time and then works suddenly. Using the same example without specifying the socket, shows that the same mpv socket is used for different instance of the MPV object. This result in sound replaced randomly.