WindowXML - Radiobutton problem
#1
Hey guys,
I am currently working on an addon, that controls a spotify instance (either a "real" spotify application or something like librespot or spotify-connect-web) using the new awesome web api endpoints spotify released a month ago or so. For this I am building my own GUI using the WindowXML class.

A worker thread checks the endpoint every second if there are changes in the playback and calls then a function inside the Main class, which updates all the controls and images accordingly.
I have implemented the play/pause button as a radiobutton, so that it can show a pause symbol, when the music is playing and a play symbol when it is not. The problem with this is now the following.
When I press the button with a bad timing, it might happen that it changes the state to play for instance (because I have pressed it) and immediately afterwards the worker thread checks the server for updates and realizes, that the music is still paused (because it needs some time) and changes the state of the radiobutton back to pause. On the next loop iteration of the worker thread the state actually has changed, leading it to change the radiobutton again to play. All this leads to a rarely occurring flicker of the button.

I hope this was somewhat understandable..
Is there any way of disabling the automatic value change of a radiobutton so that its state is only determined from one place?
I have already tried to substitute it with a normal button and, since there is no method to change the image from the code, assign a variable to the texture flag, but it cannot load the texture.
I thought about putting a "blank" button with no texture at all right under a image, that I can change from the code, but since there is no texturefocus and texturenofocus flag I would have to change it even on selected or something and that is all not really beautiful imo.

I am thankful for every suggestion how to solve this issue..
Reply
#2
No Ideas anybody? Sad

Than maybe somebody can help me with this:
I need to implement a button to control repeat, which needs to take 3 states (repeat off, repeat all and repeat one) is there a control in kodi where you can define 3 textures, that you can change from the code?
Reply
#3
I'd try placing buttons with different image textures on the same spot.
Then have the desired button be visible according to the status.

likewise, a similar set of buttons for the play/pause. only have that function on the Main class update button visibilities/status.
that way you won't run into a situation where your ui is showing a different status than the server.
then hide the delays with a "loading" gif.
Reply
#4
Thank you! thanks to your hint I got it working Smile
I hat to also change the navigation and the selected state from the code though, so for future generations heres how I did it:

This is what is in the XML
Code:
<control type="button" id="1101">
                <description>Play</description>
                <centerright>50%</centerright>
                <centertop>50%</centertop>
                <width>130</width>
                <height>130</height>
                <visible>!Control.IsVisible(1102)</visible>
                <texturenofocus colordiffuse='grey'>play.png</texturenofocus>
                <texturefocus>play.png</texturefocus>
                <onleft>1006</onleft>
                <onright>1005</onright>
            </control>
            <control type="button" id="1102">
                <description>Pause</description>
                <centerright>50%</centerright>
                <centertop>50%</centertop>
                <width>130</width>
                <height>130</height>
                <texturenofocus colordiffuse='grey'>pause.png</texturenofocus>
                <texturefocus>pause.png</texturefocus>
                <onleft>1006</onleft>
                <onright>1005</onright>
            </control>
            <control type="button" id="1005">
                <description>Next</description>
                <centerright>40%</centerright>
                <centertop>50%</centertop>
                <width>70</width>
                <height>70</height>
                <visible>true</visible>
                <texturenofocus colordiffuse='grey'>next.png</texturenofocus>
                <texturefocus>next.png</texturefocus>
                <onleft>1101</onleft>
                <onright>1007</onright>
            </control>
            <control type="button" id="1006">
                <description>Previous</description>
                <centerleft>40%</centerleft>
                <centertop>50%</centertop>
                <width>70</width>
                <height>70</height>
                <visible>true</visible>
                <texturenofocus colordiffuse='grey'>previous.png</texturenofocus>
                <texturefocus>previous.png</texturefocus>
                <onleft>1008</onleft>
                <onright>1004</onright>
            </control>

and this is what I call from the code:
Code:
def togglePlayPause(self, is_playing):
        self.pause.setVisible(is_playing)
        if is_playing:
            self.next.controlLeft(self.pause)
            self.previous.controlRight(self.pause)
        else:
            self.setFocus(self.play)
            self.next.controlLeft(self.play)
            self.previous.controlRight(self.play)
this function is called from another function which checks the server for updates.

Now I just have to implement the same for the repeat button Smile
Reply

Logout Mark Read Team Forum Stats Members Help
WindowXML - Radiobutton problem0