Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1

    Is it hard to do a rating layer (stars) on the duet now playing screen?

    Is it hard to do a rating layer (stars) on the duet now playing screen so that you just can use the wheel to rate the song instead of a couple of clicks which is too much for a human to feel convenient :-)

  2. #2
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    11,060
    Quote Originally Posted by joggs View Post
    Is it hard to do a rating layer (stars) on the duet now playing screen so that you just can use the wheel to rate the song instead of a couple of clicks which is too much for a human to feel convenient :-)
    If you wish this as a user, please post you comment in enhancement request #142, which at the moment is scheduled for 7.3.

    It can't me implemented easily as a third party plugin, I think you would have to re-implement the whole Now Playing screen. At the moment the only way for a user to change ratings in SqueezeCenter is through third party plugins (TrackStat or iTunes Update).

    If you are interesting in looking at the Controller code and try to implement this yourself, please say so and I'm sure someone with better knowledge of the Controller code could give you some pointers what to look at.
    Erland Isaksson (My homepage)
    Developer of many plugins/applets

  3. #3
    Senior Member
    Join Date
    Jul 2010
    Posts
    105
    Quote Originally Posted by erland View Post
    If you wish this as a user, please post you comment in enhancement request #142, which at the moment is scheduled for 7.3.

    It can't me implemented easily as a third party plugin, I think you would have to re-implement the whole Now Playing screen.
    Hello Erland.

    I've been trying to get the NowPlaying screen (Touch, piCorePlayer) to display track ratings. So I took a look at the nowplaying.applet. Your CustomClock(Helper) was a great source of inspiration.
    I have 2 very specific questions and I hope you can point me in the right direction.

    Since I have my ratings stored in the comment tag I started this whole enterprise by adding a function that gets the comment tag value for the current track - which in turn translates into stars.
    Code:
    function _updateTitleFormatInfo(self,player)
    	local server = self.player:getSlimServer()
    	if server then
    		server:userRequest(function(chunk,err)
    				if err then
    					log:warn(err)
    				else
    					local index = chunk.data.playlist_cur_index
    					if index and chunk.data.playlist_loop[index+1] then
    						self.titleformats["COMMENT"] = chunk.data.playlist_loop[index+1].comment
    					else
    						self.titleformats = {}
    					end
    				end
    			end,
    			player and player:getId(),
    			{'status','0','100','tags:k'}
    		)
    	end
    end
    Then I add "self:_updateTitleFormatInfo(self.player)" to some functions of the nowplaying.applet, in particular the showNowPlaying and the _updateTrack functions.

    It works but when I forward to the next track the displayed rating value is the one of the previous track and it takes around 10 seconds before it updates to the rating value of the current track.
    Does it take my function that long to get a response with the comment tag value from the server with the comment tag value? Is that normal or am I just doing it the wrong way?
    If that kind of time lag is normal how could I display no value (blank instead of the wrong value) until the correct value is returned from LMS?

    [EDIT: delete everything concerning Trackstatrating to focus on the comment tag solution]

    I spent a really long time with trial and error getting to his point and I would be very glad if you could give me some hints because it seems like I'm almost there.
    Thank you so much.
    Regards,

    A.
    Last edited by afriend; 2020-08-15 at 08:11.

  4. #4
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    1,065
    Quote Originally Posted by afriend View Post
    Then I add "self:_updateTitleFormatInfo(self.player)" to some functions of the nowplaying.applet, in particular the showNowPlaying and the _updateTrack functions.
    Why not call it exactly once ?

    It works but when I forward to the next track the displayed rating value is the one of the previous track and it takes around 10 seconds before it updates to the rating value of the current track.
    Does it take my function that long to get a response with the comment tag value from the server with the comment tag value? Is that normal or am I just doing it the wrong way?
    Have you actually measured how long (and where) the delay is introduced (e.g. by adding a few debug statements to the code) ?
    That being said, the additional call will always add a delay, why not use the existing self.player:getPlayerStatus() instead?

    If that kind of time lag is normal how could I display no value (blank instead of the wrong value) until the correct value is returned from LMS?
    Have you tried setting self.titleformats["COMMENT"] to blank?

    And my second question: I think your plugin Trackstat adds some titleformats to LMS, among them TRACKSTATRATINGNUMBER.
    If I wanted the NowPlaying Applet to get the current value of TRACKSTATRATINGNUMBER from LMS, what would that query look like?
    TrackStat adds a getrating command which you can call (params: 'trackstat','getrating', 'trackid'). This will add another delay, so why not use the existing rating instead?
    Various SW: Web Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | LMSlib2go | ...
    Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

  5. #5
    Senior Member
    Join Date
    Jul 2010
    Posts
    105
    First of all, thank you so much for taking the time to answer. I really appreciate it very much. And please will you excuse my ignorance. I'm only a hobbyist or code tinkerer.

    Quote Originally Posted by Roland0 View Post
    Have you actually measured how long (and where) the delay is introduced (e.g. by adding a few debug statements to the code) ?
    I totally would use the log:debug command to get ahead because it's so helpful. The thing is - I can't find the log output on my mac. I use the SqueezePlay app on my mac (10.15) to "work" on the NowPlaying applet. At first I thought the log output (that I had set to debug in SqueezePlay) would end up in the LMS server.log but there was nothing (even though I set every log category in the server settings to debug that I thought could be related).
    Then I read in the SqueezePlay wiki I should look for it in the console on my mac. But nothing there either it seems... So until I find the log output I'm blind and what can I do but trial and error...

    Quote Originally Posted by Roland0 View Post
    why not use the existing self.player:getPlayerStatus() instead?
    That sounds super interesting. And of course I hadn't thought of that yet at all. Just so I understand, can I just ask:

    do you mean that LMS sends the comment tag value to the player by default as part of the track metadata? No need for further queries to the server?

    In the NowPlaying applet the extracted trackinfo seems limited to track title, track artist and track album (maybe album artist).

    Code:
    local playerStatus = self.player and self.player:getPlayerStatus()
    (..)
    local trackInfo = self:_extractTrackInfo(playerStatus.item_loop[1])
    (...)
    function _extractTrackInfo(self, _track)
    	if _track.track then
    		local returnTable = {}
    		table.insert(returnTable, _track.track)
    		table.insert(returnTable, _track.artist)
    		table.insert(returnTable, _track.album)
    		return returnTable
    	else
    		return _track.text or "\n\n\n"
    	end
    end
    If the player already has more metadata than title, (a)artist and album how would I get the command value from the player? Looking for _track.comment in the extractTrackInfo function yields nothing (probably no surprise to you).

    Since I can't find any log output on my mac, what information does the playerstatus query return and in which form?

    Again, as I said, please excuse my ignorance. I would appreciate any kind of hint that point me in the right direction.
    Thanks for your help.

  6. #6
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    1,065
    Quote Originally Posted by afriend View Post
    Then I read in the SqueezePlay wiki I should look for it in the console on my mac. But nothing there either it seems... So until I find the log output I'm blind and what can I do but trial and error...
    How do you start SqueezePlay? If you run it from the console / terminal, you should see the messages there.
    If not, check userpath/logconf.lua (esp. the appender conf)


    That sounds super interesting. And of course I hadn't thought of that yet at all. Just so I understand, can I just ask:
    do you mean that LMS sends the comment tag value to the player by default as part of the track metadata?
    Since I can't find any log output on my mac, what information does the playerstatus query return and in which form?
    The info to be included is defined in Player.lua in the function onStage:
    Code:
    	-- subscribe to player status updates
    	local cmd = { 'status', '-', 10, 'menu:menu', 'useContextMenu:1', 'subscribe:600' }
    	self.slimServer.comet:subscribe(
    		'/slim/playerstatus/' .. self.id,
    		_getSink(self, cmd),
    		self.id,
    		cmd
    	)
    SInce the tags parameter is omitted, it's the default ('gald')
    You can either add non-default tags here (ugly, but simple) or do your own subscription in the NowPlayingApplet (cleaner, as you are not modifying Logitech's library, but more effort. Check the function _process_status in Player.lua)
    Various SW: Web Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | LMSlib2go | ...
    Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

  7. #7
    Senior Member
    Join Date
    Jul 2010
    Posts
    105
    Quote Originally Posted by Roland0 View Post
    If you run it from the console / terminal, you should see the messages there.
    I can't believe I forgot this. (appender conf is empty BTW)

    I couldn't get the subscribe function you suggested to work. But I think I can live with what the server:userrequest (songinfo) returns. It works without much delay. Ok, it doesn't blank the value if you press forward but I can live with that.
    I'll post everything in a dedicated thread soon so that others interested in this will find it more easily. Thanks for your help.
    Last edited by afriend; 2020-08-21 at 13:29.

  8. #8
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    1,065
    Quote Originally Posted by afriend View Post
    I can't believe I forgot this. (appender conf is empty BTW)

    I couldn't get the subscribe function you suggested to work.
    If you are going to change the base squeezeplay install anyway (e.g. by modifying the skin), I'd really recommend changing the subscription in Player.lua as described above (see the status command in the CLI doc for details)
    If you do that, you won't have to send any requests to the server, simplifying everything significantly. All the info you need will be available in self.player:getPlayerStatus() anywhere in the applet.

    Also, you may want to get rid of those if constructs by using captures instead.
    Various SW: Web Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | LMSlib2go | ...
    Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

  9. #9
    Senior Member
    Join Date
    Jul 2010
    Posts
    105
    Quote Originally Posted by Roland0 View Post
    If you are going to change the base squeezeplay install anyway (e.g. by modifying the skin), I'd really recommend changing the subscription in Player.lua as described above (see the status command in the CLI doc for details)
    If you do that, you won't have to send any requests to the server, simplifying everything significantly. All the info you need will be available in self.player:getPlayerStatus() anywhere in the applet.
    I really did try that first. I added k which is for comment tag (the same for the songinfo request):
    Code:
    local cmd = { 'status', '-', 10, 'tags:galdk', 'menu:menu', 'useContextMenu:1', 'subscribe:600' }
    I checked the entire reponse I got and maybe I did it wrong but playerStatus.item_loop[1].params only ever returned the same values (track_id and playlist_index position) as before.

    I will definitely take a look at the captures and see if I can figure that out.

  10. #10
    Senior Member
    Join Date
    Aug 2012
    Location
    Austria
    Posts
    1,065
    Quote Originally Posted by afriend View Post
    I really did try that first. I added k which is for comment tag (the same for the songinfo request):
    Code:
    local cmd = { 'status', '-', 10, 'tags:galdk', 'menu:menu', 'useContextMenu:1', 'subscribe:600' }
    Looks fine to me

    I checked the entire reponse I got and maybe I did it wrong but playerStatus.item_loop[1].params only ever returned the same values (track_id and playlist_index position) as before.
    see the _extractTrackInfo in Player.lua for how to access the status (basically playerStatus.item_loop[1].artist etc.)

    Maybe helpful: How to dump a table to console?
    Various SW: Web Interface | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | LMSlib2go | ...
    Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •