Solved Adding Custom Toggle Button To Estuary's VideoOSD.xml
#1
Code:
Hi,

I want to add a toggle button to Estuary's player OSD - in VideoOSD.xml file.
the toggle button runs an addon's script. and toggles it's actions to on/off

I am using these two icons for the button:
https://imgur.com/a/YjuY2vq
https://imgur.com/a/15sAnTA
Image Image


The default icon is for OFF - white "IMAX" icon, and when clicking I want to change the icon image to ON - the green "IMAX" icon.

How do I configure it to use the same toggle button and change the icon image on button click?
For now I've put the two icons next to each other:
https://imgur.com/a/Rm1NCCS
Image

Using this code: (the first button "settings-subtitle" is original Estuary button, copied it's code to create the custom button):

xml:
<control type="radiobutton" id="70046">
    <include content="OSDButton">
        <param name="texture" value="osd/fullscreen/buttons/settings-subtitle.png"/>
    </include>
    <onclick>ActivateWindow(osdsubtitlesettings)</onclick>
    <visible>!VideoPlayer.Content(LiveTV) | VideoPlayer.HasSubtitles</visible>
</control>
<control type="radiobutton" id="700452">
    <include content="OSDButton">
        <param name="texture" value="imax/imax_off.png"/>
    </include>
    <onclick>RunScript(plugin.custom.script,do_something)</onclick>
</control>
<control type="radiobutton" id="700453">
    <include content="OSDButton">
        <param name="texture" value="imax/imax_on.png"/>
    </include>
    <onclick>RunScript(plugin.custom.script,do_something)</onclick>
</control>
Reply
#2
Since you're using a radio button, you can set the image depending on the state of the button and then have only one button control.  Take a look at the docs at:

https://kodi.wiki/view/Radio_button_control

Specifically look at the entries for textureradioon and textureradiooff.  That will toggle the image based on the state of the button.

Your code example has the same entry for the onclick, so I'm assuming your script knows how to figure out the current state of the thing and change it accordingly.  If that isn't true, what I'm suggesting might not be as helpful.
Reply
#3
(2023-06-17, 12:48)pkscout Wrote: Since you're using a radio button, you can set the image depending on the state of the button and then have only one button control.  Take a look at the docs at:

https://kodi.wiki/view/Radio_button_control

Specifically look at the entries for textureradioon and textureradiooff.  That will toggle the image based on the state of the button.

Your code example has the same entry for the onclick, so I'm assuming your script knows how to figure out the current state of the thing and change it accordingly.  If that isn't true, what I'm suggesting might not be as helpful.

The code that will run will do do something to switch between on/off state, but I don't think the skin can know the changes. it will always do the same onclick function:
RunScript(plugin.custom.script,do_something)

I couldn't see a specific example in the link for textureradioon/textureradiooff, only for textureradioonfocus/textureradioofffocus. Do you have code example based on my radio button?
Reply
#4
(2023-06-17, 12:56)barronen1 Wrote: I couldn't see a specific example in the link for textureradioon/textureradiooff, only for textureradioonfocus/textureradioofffocus. Do you have code example based on my radio button?
As noted in the documentation, textureradioon and textureradiooff can be used in place of two different entries (textureradioonfocus and textureradioonnofocus in the case of textureradioon for instance).  So if you look at the example radio button in the documentation where it has entries for textureradioonfocus and textureradioonnofocus, you can use just textureradioon instead.

This is just going to change the image depending on the radio button state.  If the radio button state and the actual state of your outside thing get out of sync, you'll have to address that manually I guess.
Reply
#5
(2023-06-17, 13:03)pkscout Wrote:
(2023-06-17, 12:56)barronen1 Wrote: I couldn't see a specific example in the link for textureradioon/textureradiooff, only for textureradioonfocus/textureradioofffocus. Do you have code example based on my radio button?
As noted in the documentation, textureradioon and textureradiooff can be used in place of two different entries (textureradioonfocus and textureradioonnofocus in the case of textureradioon for instance).  So if you look at the example radio button in the documentation where it has entries for textureradioonfocus and textureradioonnofocus, you can use just textureradioon instead.

This is just going to change the image depending on the radio button state.  If the radio button state and the actual state of your outside thing get out of sync, you'll have to address that manually I guess.
This is code I wrote:


xml:
                    <control type="radiobutton" id="700452">
                        <include content="OSDButton">
                            <param name="texture" value="imax/imax_off_white.png"/>
                        </include>
                        <textureradiooff>imax/imax_off_white.png</texturefocus>
                        <textureradioon>imax/imax_on_green.png</texturefocus>
                        <onclick>RunScript(plugin.custom.script,do_something)</onclick>
                    </control>


Using this code it screwed the player OSD, it doesn't load up at all.
Reply
#6
(2023-06-17, 13:11)barronen1 Wrote: This is code I wrote:


xml:
                    <control type="radiobutton" id="700452">
                        <include content="OSDButton">
                            <param name="texture" value="imax/imax_off_white.png"/>
                        </include>
                        <textureradiooff>imax/imax_off_white.png</texturefocus>
                        <textureradioon>imax/imax_on_green.png</texturefocus>
                        <onclick>RunScript(plugin.custom.script,do_something)</onclick>
                    </control>


Using this code it screwed the player OSD, it doesn't load up at all.

Your XML is bad. You opened the tag with textureradiooff and then never closed it because you have /texturefocus as the "closing" tag. Same for the second entry. If you don't really understand XML, this might not be the best enhancement for you to be working on. If you want to continue, at least validate your XML before asking for additional help.

https://www.xmlvalidation.com
Reply
#7
(2023-06-17, 16:20)pkscout Wrote:
(2023-06-17, 13:11)barronen1 Wrote: This is code I wrote:


xml:
                    <control type="radiobutton" id="700452">
                        <include content="OSDButton">
                            <param name="texture" value="imax/imax_off_white.png"/>
                        </include>
                        <textureradiooff>imax/imax_off_white.png</texturefocus>
                        <textureradioon>imax/imax_on_green.png</texturefocus>
                        <onclick>RunScript(plugin.custom.script,do_something)</onclick>
                    </control>


Using this code it screwed the player OSD, it doesn't load up at all.

Your XML is bad. You opened the tag with textureradiooff and then never closed it because you have /texturefocus as the "closing" tag. Same for the second entry. If you don't really understand XML, this might not be the best enhancement for you to be working on. If you want to continue, at least validate your XML before asking for additional help.

https://www.xmlvalidation.com

Didn't notice the typo. I got it working with this code:

xml:
<control type="radiobutton" id="700452">
    <textureradioofffocus colordiffuse="white">imax/imax_off_white.png</textureradioofffocus>
    <textureradiooffnofocus>imax/imax_off_white.png</textureradiooffnofocus>
    <textureradioonfocus colordiffuse="white">imax/imax_on_green.png</textureradioonfocus>
    <textureradioonnofocus>imax/imax_on_green.png</textureradioonnofocus>
    <textureradiooffdisabled colordiffuse="disabled">imax/imax_off_white.png</textureradiooffdisabled>
    <textureradioondisabled colordiffuse="disabled">imax/imax_on_green.png</textureradioondisabled>
    <texturefocus colordiffuse="button_focus">osd/fullscreen/buttons/button-fo.png</texturefocus>
    <width>76</width>
    <animation center="38,38" effect="zoom" end="100" reversible="false" start="95" time="480" tween="back">Focus</animation>
    <height>76</height>
    <radiowidth>74</radiowidth>
    <radioheight>74</radioheight>
    <font></font>
    <texturenofocus />
    <radioposx>1</radioposx>
    <radioposy>0</radioposy>
</control>
Reply
#8
Thread marked solved.
Reply
#9
(2023-06-17, 13:03)pkscout Wrote:
(2023-06-17, 12:56)barronen1 Wrote: I couldn't see a specific example in the link for textureradioon/textureradiooff, only for textureradioonfocus/textureradioofffocus. Do you have code example based on my radio button?

This is just going to change the image depending on the radio button state.  If the radio button state and the actual state of your outside thing get out of sync, you'll have to address that manually I guess.


Hi,

The onclick function of the button is a toggle function (hence the radio button)

The dev of the addon said that the current toggle status (on/off) is accessible through:
py:
xbmcgui.Window(10000).getProperty('blackbarsnever_status')

How can I use it to sync the radio button images with the toggle function status?
Reply
#10
(2023-06-19, 17:25)barronen1 Wrote: The dev of the addon said that the current toggle status (on/off) is accessible through:
py:
xbmcgui.Window(10000).getProperty('blackbarsnever_status')

How can I use it to sync the radio button images with the toggle function status?

I don't think you can. Now that there is a way to tell the current state, you might be better off with two buttons that use the visibility option to only show the one that would change the state.

Here's a single button:

https://kodi.wiki/view/Skinning_Manual#Button_Control

And information on how to use the visible tag with a conditional to show the right one:

https://kodi.wiki/view/Default_control_tags

Because the information from a window property is a string, you probably need to use String.IsEqual to check the value:

https://kodi.wiki/view/List_of_boolean_c...ons#String
Reply

Logout Mark Read Team Forum Stats Members Help
Adding Custom Toggle Button To Estuary's VideoOSD.xml0