Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 8 of 8
  1. #1
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    806

    Help requested with ScreenSavers applet

    I'm trying to tweak the behaviour of the Jivelite ScreenSavers applet to make it more appropriate for a device that only controls other players connected to LMS. I've built Jivelite for use on a Joggler (see Jivelite on a Joggler), which is a touchscreen device. I've been posting about this issue in that thread, but I don't think it's necessarily a Joggler-specific issue, so I'm posting here in the hope of getting wider input.

    My use case is probably self-evident: Since my build of Jivelite does not include Squeezelite (no need for it), there is no 'local' player, and hence no 'while off' screen saver. The only way to make a clock screensaver appear is to pause the currently selected player, and if that player happens to be in a synced group then playback stops everywhere.

    My intended behaviour is to allow the 'when off' screensaver to activate when the currently selected player is powered off. I'd also like to be able to touch the screen to wake it, and select a different player, without the currently selected player being powered up.

    I'm making progress (see here), but I'm stuck on a specific issue, so I'm hoping someone can help. I'd also appreciate thoughts on my 'intended behaviour', and whether there's an easier way to achieve this.

    Here's what I've done so far.
    1) I commented out the check on whether there's a local player.
    Code:
    	-- only present a WHEN OFF option when there is a local player present
    --	if Player:getLocalPlayer() then
    		menu:addItem(
    			{
    				text = self:string("SCREENSAVER_WHEN_OFF"),
    				weight = 2,
    				sound = "WINDOWSHOW",
    				callback = function(event, menu_item)
    						   self:screensaverSetting(menu_item, "whenOff")
    					   end
    			}
    		)
    --	end
    This meant that the 'whenOff' screensaver option is now available on my player-less Joggler. And it seems to work as expected. However, while the 'whenOff' screensaver is displaying, touchscreen events are ignored, so it's not possible to touch the screen to wake the Joggler.

    2) I fixed this behaviour by commenting out the code that prevents processing of the mouse event:
    Code:
    			if event:getType() == EVENT_MOUSE_PRESS or
    			   event:getType() == EVENT_MOUSE_HOLD or
    			   event:getType() == EVENT_MOUSE_DRAG then
    				if self.mouseAllowed then
    					log:debug("'Per window' mouse event allowed to pass through")
    --					return EVENT_UNUSED
    
    				end
    			end
    			log:debug("Closing screensaver event=", event:tostring())
    
    			self:deactivateScreensaver()
    So now I can touch the screen to deactivate the 'whileOff' screensaver, but in doing so it also powers up the currently selected player. That's not always desirable, e.g. if it's a Radio in a bedroom.

    3) I fixed this behaviour by commenting out the code that powers up the player.
    Code:
    	if not self:isSoftPowerOn() then
    --		jiveMain:setSoftPowerState("on")
    	end
    So now I'm very nearly there. The issue I now have, that I'd appreciate help with, is that when I switch players, the 'whenOff' screen saver appears to continue to respond to the power state of the previously selected player, i.e. I touch the screen to wake the Joggler, select a different player that is NOT powered off, but the 'whenOff' screensaver continues to activate because the previous player is still powered off. If I cycle the power on the 'new' player, then the behaviour of the 'whenOff' screensaver is corrected. I'm guessing I need to update the screensaver code to listen for the power status of the new player somehow, but I'm at a loss as to how to do this. The odd thing is that the 'when stopped' screensaver DOES appear to respond to the new player's status already.
    Last edited by chill; 2019-02-03 at 07:09.

  2. #2
    Senior Member ralphy's Avatar
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    2,073
    Revert changes #2 and #3 and try this change. Patch file attached.

    Code:
    Index: share/jive/applets/ScreenSavers/ScreenSaversApplet.lua
    ===================================================================
    --- share/jive/applets/ScreenSavers/ScreenSaversApplet.lua
    +++ share/jive/applets/ScreenSavers/ScreenSaversApplet.lua
    @@ -559,7 +559,7 @@
     
            if not self:isSoftPowerOn() then
                    --allow input to pass through, so that the following listeners will be honored
    -               self:_setSSAllowedActions(true, {}, true)
    +               --self:_setSSAllowedActions(true, {}, true)
     
                    window:ignoreAllInputExcept(    { "power", "power_on", "power_off" },
                                                    function(actionEvent)
    Attached Files Attached Files
    Ralphy

    1-Touch, 5-Classics, 3-Booms, 1-UE Radio
    Squeezebox client builds donations always appreciated.

  3. #3
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    806
    Thanks Ralphy, I'll give that a go this evening.

  4. #4
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    806
    I tried that - similar result as with my edits. If I switch to a 'new' player that has a different power state from the 'old' player, the 'whenOff' screensaver seems to continue to respond to the power state of the old player. Power cycling the 'new' player makes the 'whenOff' screensaver respond to the power state of the new player.

    And I had to reapply my change #3, otherwise the currently selected player gets powered up when I touch the screen while the 'when off' screen saver is showing.

    So, how to make the 'whenOff' screensaver obey the power state of the new player? What gets updated/restarted when the current player is turned off/on (one of the timers?), and can that be actioned without having to cycle the power?

  5. #5
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    806
    Apologies - I posted this in the wrong thread, so I'm reposting here where it's more relevant.

    I've found a fix to the 'whenOff' screensaver issue. The issue was that the screensaver was responding to the power state of the previous player, rather than the current one - i.e. if I switched to a player that was off, but the previous player was still on, I'd get the 'whenStopped' screensaver rather than the 'whenOff' screensaver (and vice versa). This could be fixed by power cycling the current player.

    I've made a tweak that seems to fix this. I commented out the line that has my initials (CJH) and replaced it with the line below it.
    Code:
    function _getMode(self)
    	local player = appletManager:callService("getCurrentPlayer")
    	
    --CJH	if not self:isSoftPowerOn() and System:hasSoftPower() then
    	if not player:isPowerOn() and System:hasSoftPower() then
    		return 'whenOff'
    	else
    		if player and player:getPlayMode() == "play" then
    			return 'whenPlaying'
    		end
    	end
    	return 'whenStopped'
    end
    I must admit I don't understand what 'self' is referring to in this function, but evidently 'self:isSoftPowerOn()' does not reflect the power state of the current player after a change of player, whereas 'player:isPowerOn()' does. I also don't know what 'System:hasSoftPower()' does - what is the 'System' here?

    If there's a better way, such as updating 'self' somehow, I'm all ears. As it stands, the screensaver applet now behaves as I think it should on a Joggler. To summarise, my changes are:
    1) A 'whenOff' screensaver is now an option even when there is no local player
    2) The screensaver now responds to the power state of the current player: 'player:isPowerOn' rather than 'self:isSoftPowerOn()'
    3) The header line of the screensaver menu is never shown - I never did understand which buttons were meant in that text, e.g. "Press the center button to choose a screensaver, play to preview."
    4) Touching the screen while the 'whenOff' screensaver is displayed now deactivates the screensaver
    5) Touching the screen while the 'whenOff' screensaver is displayed no longer wakes the current player

  6. #6
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    806
    'system:hasSoftPower' seems to refer to the device that Jivelite is running on - I found this in system.lua:
    Code:
    function hasSoftPower(self)
    	return ( self:hasTouch() or self:hasPowerKey() )
    end
    With my reconfigured screensaver applet I don't think it matters whether the controlling device has a power button - it doesn't seem relevant if I'm triggering the screensaver according to the status of the currently selected player, which can be changed from any number of external interfaces.

    So I simplified the _getMode function:
    Code:
    function _getMode(self)
    	local player = appletManager:callService("getCurrentPlayer")
    	
    	if player then
    		if not player:isPowerOn() then
    			return 'whenOff'
    		else
    			if player:getPlayMode() == "play" then
    				return 'whenPlaying'
    			end
    		end
    	end
    	return 'whenStopped'
    end
    This function only cares whether the current player is powered off ('whenOff') or playing ('whenPlaying'), and returns 'whenStopped' otherwise (even if no player is selected). For a device that is principally a controller, this applet seems to work more intuitively now, and doesn't distinguish between a local player and other players.
    Last edited by chill; 2019-02-19 at 06:51.

  7. #7
    Senior Member ralphy's Avatar
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    2,073
    Great sleuthing! Following the lua code paths in jivelite/squeezeplay is usually a challenge.

    I haven't had a lot of time to play with the _getMode change but it's a welcome change to my picoreplayer controller.

    I will use it for a while first, but will likely apply your change to the pcp jivelite extension too.

    Thanks.
    Ralphy

    1-Touch, 5-Classics, 3-Booms, 1-UE Radio
    Squeezebox client builds donations always appreciated.

  8. #8
    Senior Member chill's Avatar
    Join Date
    Mar 2007
    Posts
    806
    Quote Originally Posted by ralphy View Post
    Following the lua code paths in jivelite/squeezeplay is usually a challenge.
    Haha - you're not kidding! I've found it quite difficult, mostly due to:
    - A general lack of experience with object-oriented programming,
    - unfamiliarity with Linux,
    - and the rather 'opaque' failure modes of my badly written lua. Since it's an interpreter, rather than a compiler, it usually just silently ignores parts of the code, without telling me where my syntax error is. I've learned to introduce new code in very small sections, and to add lots of debugging outputs.

Posting Permissions

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