ondras / cyp

Control Your Player: a Web-based MPD client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Queue is not updated

stefanroellin opened this issue · comments

If another mpd client changes the queue, it is not updated, if the queue is currently visible. After changing to another tab and back to the queue, it is updated and shows the correct information.

Right, the queue is not monitored in any way, so external modifications have no means of propagating into the player. My main use case is CYP being the single/only client, so this is not something that really bothers me. If there is a straightforward solution, I am open to implementing it. Just I am currently not sure what is the proper way here.

Thanks for the information. It would be a nice-to-have feature, but since one can force an update by changing to another tab and back, it is not a big problem.

Using the built-in MPD mechanism for change notifications is definitely a proper way to go; there are more use cases where this would be beneficial (such as the CYP player component polling the playback status every second to stay in sync; this is obviously sub-optimal). I have already added the necessary functionality to the underlying ws2mpd bridge.

Modifying CYP itself is trickier than I initially thought, though. I am struggling a bit right now, but I believe I would be able to adjust the code to fully support the idle command. If I fail, we will remain with the status quo.

Dear @stefanroellin ,

would you be willing to test out the refactored code from the idle branch? This version shall stay in sync with changes made by other MPD clients. Note that you need to npm i after updating, because I had to fix and bump several dependencies.

I tested the idle branch a bit. The update of the queue now works great! Thanks for that.
However, if the volume is changed by another client, it does not update anymore. On the master branch it was updated.
Other than that I did not see a problem yet.

However, if the volume is changed by another client, it does not update anymore. On the master branch it was updated.

Right. The master branch achieves this by frequent polling (every second) of the server state. I tried to evade this.

Listening to "volume change" events on the idle branch is problematic, though, because a casual interaction with the volume slider results in many individual volume updates, interspersed with an equal number of "volume change" notifications coming back from the server. My humble opinion here is that this particular case is architected problematically with respect to MPD. Will try to come up with an alternative solution.

Thanks for testing!

@stefanroellin, please try updating and npm i again. The volume changed in other clients shall be reflected now.

If another client updates anything in mpd, it is immediately updated in cyp. This is really nice - thanks!
However, I have restarted mpd by mistake and after that, cyp did not recover.
Turning on logging, the last two lines were:

1589048206041 'mpd disconnected'
1589048206043 'ws ::1 disconnected'

After that no line was logged anymore.
In the development tool in the browser I got:

cyp.js:291 Uncaught (in promise) 
CloseEvent {isTrusted: true, wasClean: true, code: 1000, reason: "Normal connection closure", type: "close", …}
...

Thanks @stefanroellin for testing!

The issue you described does not actually happen to be related to this whole mpd-notification refactor; the said functionality (re-connecting to a broken socket) simply has not been implemented yet (nor here nor in the master branch).

I will create a separate issue to track, because being able to re-connect sounds like a reasonable idea.

Merged into master, closing.