v19 Control.setVisibleCondition & onControl don't work properly
#1
Hi,

I have two buttons of Play and Pause, one above the other (The same x,y,w,h), kind of a toggle button.
The button visibilty is actually changed:
* When the Play icon is shown: When pressing on it, the Player start playing and the icon is changed to Pauses.
But when the Pause icon is shown: When pressing on it, the Player start playing again instead of pausing,
The onLoad function getting the control as the Play button id and not the Pause one, and the icon is of course stay on the Play icon.

What am I missing here?
Thanks.

Code:
self.play = xbmcgui.ControlButton(...)
self.pause = xbmcgui.ControlButton(...)

self.addControls([..., ... ,  self.prev, self.next])

# set visibility:
self.play.setVisibleCondition('[!Player.Playing]', True)      
self.pause.setVisibleCondition('[Player.Playing]', True)



    def onControl(self, control):
        _controlID = control.getId()
        if _controlID == self.pause.getId():
            Player().pause()
        elif _controlID == self.play.getId():
            Player().play(strm)
Reply
#2
Try setFocus() on the active button when you toggle buttons.
Reply
#3
(2021-09-30, 08:05)Roman_V_M Wrote: Try setFocus() on the active button when you toggle buttons.

I tried this like this:

Code:
    def onControl(self, control):
        
        _controlID = control.getId()
        if _controlID == self.pause.getId():
            Player().pause()
            self.setFocus(self.play)
        elif _controlID == self.play.getId():
            Player().play(...)
            self.setFocus(self.pause)

But still the same the "if _controlID == self.pause.getId():" never works,
all the time the "elif _controlID == self.play.getId():" works instead.
Reply
#4
@Roman_V_M 

Ok I found the solution:
instead of using setFocus(), I'm using setEnable()

Code:
    def onControl(self, control):
     
        _controlID = control.getId()
        if _controlID == self.pause.getId():
            self.pause.setEnabled(False)
            self.play.setEnabled(True)           
            Player().pause()
        elif _controlID == self.play.getId():
            self.pause.setEnabled(True)   
            self.play.setEnabled(False)
            Player().play(...)

But the problem now is that the Player().pause() doesn't to its work, the Player continues to play.
However, Player().stop() does do the work.
So what is the difference between them, why does stop() actually stop the player while pause() doesn't do anything?
Reply

Logout Mark Read Team Forum Stats Members Help
Control.setVisibleCondition & onControl don't work properly0