Re: LMS & time/timer/timing
Michael Herger <slim-b/[email protected]> Sun, 7 Aug 2022 17:27:01 +0200
| Newsgroups | gmane.music.equipment.slimdevices.devel |
|---|---|
| Message-ID | <[email protected]> |
> seems that even the default skin is "only" refreshed every x seconds or > does it get notified of these server events? Sounds weird but I'm goint That's correct, it's polling every five seconds, IIRC. > to ask anyway: can a web page subscribe to LMS server events? Yes, nowadays that's possible. I always wanted to add this to the Default skin... but never did it. I think Material skin does it. It's using long-polling: eg. the server wouldn't hang up the connection once it has sent a response, but leaves it open, so the server can send more data back. Once it hangs up, the browser would immediately re-connect. That was state of the art a decade or more back :-). Nowadays websockets are the standard way to do this kind of things. But LMS doesn't support it, and adding support for it seems to be non-trivial. > BTW can you recommend a documentation on the -Ext JS Library- that LMS > uses if there is any? Haven't really had to use it before. Just curious. > Not sure it plays a part here. Thank you. https://docs.sencha.com/extjs/4.2.2/#!/api But what you'd probably want is to look into "SqueezeJS" (https://wiki.slimdevices.com/index.php/SqueezeJS.html), the library I wrote on top of ExtJS to create the Default skin. The documention obviously is mostly inexistent... but the code is your friend! The framework defines a few events to which you can subscribe: https://github.com/Logitech/slimserver/blob/public/8.3/HTML/EN/html/SqueezeJS/Base.js#L59 There's eg. `playtimeupdate`. If you subscribed to it you could update your content whenever the playtime changes. Obviously this will suffer from some lag in case the polling rate was too slow. But in many cases it's good enough anyway. 'playerstatechange' or 'playlistchange' might be of interest, too. If you search around the JS source in LMS you'll find use cases for these you can learn from.