Control event from addon
#1
Hello,

I have edited the VideoOSD.xml to change the seek bar to a slider. Now i would like to find the way to control it from python, am i in the right direction by doing it from a service addon? What i would like to do is when the player start setting min and max value then be able to get and set value of this slider. Can someone help me to start ? Thanks
Reply
#2
Can you help me with a code snippet for example there is an event when a window open ? thanks ...
Reply
#3
Take a look at how Callbacks does it.
Any possible event is coded in there somewhere - eg 'onWindowOpen' which is presumably what you're looking at.
Reply
#4
I trogggy,

I have already try to use this but there is no simple and clear code part that i could use...

I have been able to trigger event like onPlayBackStarted like below :

Code:
class XBMCPlayer( xbmc.Player ):

    def __init__( self, *args ):
        pass

    def onPlayBackStarted( self ):
        xbmc.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
        xbmc.log(str(xbmcgui.getCurrentWindowId()))
        xbmc.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
      
player = XBMCPlayer()


while(not xbmc.abortRequested):
    xbmc.sleep(100)

But doing the same with window open i don't find how ...
Reply
#5
So here is where i am :

Code:
#!/usr/bin/python

import xbmc
import xbmcgui
import subprocess
import os.path
import re
import time


class XBMCPlayer( xbmc.Player ):

    def __init__( self, *args ):
        pass

    def onPlayBackStarted( self ):
        w = xbmcgui.WindowDialog(12901) # 12901 VideoOSD.xml id
        c = w.getControl(9000) # 9000 ID of slider control
        c.setPercent(50)

        xbmc.log("DEBUT -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
        xbmc.log(c.getPercent())
        xbmc.log("FIN -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
  
player = XBMCPlayer()


while(not xbmc.abortRequested):
    xbmc.sleep(100)


XML for VideoOSD.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<window>
    <!-- videoosd -->
    <defaultcontrol always="true">5</defaultcontrol>
            <animation type="WindowOpen">
                <effect type="zoom" start="90" end="100" center="auto" tween="back" easing="out" time="200"/>
                <effect type="fade" start="0" end="100" time="200"/>
            </animation>

    <controls>

        
        
        <!-- Player forwarding/rewinding -->
        <control type="group">
            <left>150</left>
            <top>795</top>
            <width>140</width>
            <height>60</height>
            <visible>!Window.IsVisible(VideoBookmarks) + !Window.IsVisible(DialogSettings.xml) + !Window.IsVisible(DialogConfirm.xml)</visible>
            <visible>player.forwarding | player.rewinding | player.paused | player.istempo</visible>
            <animation type="WindowOpen" condition="!Window.IsActive(seekbar) + !Window.IsActive(fullscreeninfo)">
                <effect type="zoom" start="90" end="100" center="auto" tween="back" easing="out" time="200"/>
                <effect type="fade" start="0" end="100" time="200"/>
            </animation>
            <animation type="WindowClose" condition="!Window.IsActive(seekbar) + !Window.IsActive(fullscreeninfo)">
                <effect type="zoom" start="100" end="90" center="auto" easing="in" time="200"/>
                <effect type="fade" start="100" end="0" time="200"/>
            </animation>

            <!-- Background -->
            <control type="image">
                <width>140</width>
                <height>60</height>
                <texture colordiffuse="$VAR[OverlayColor]">dialogs/Background.png</texture>
            </control>

            <!-- Status -->
            <control type="label">
                <width>140</width>
                <height>60</height>
                <font>Font36</font>
                <align>center</align>
                <label>$VAR[PlayerStatus]</label>
                <textcolor>DialogColor2</textcolor>
            </control>

            <!-- Pause -->
            <control type="image">
                <left>40</left>
                <width>60</width>
                <height>60</height>
                <texture colordiffuse="DialogColor1">osd/OSDPauseNF.png</texture>
                <visible>player.paused</visible>
            </control>

        </control>

        <!-- Player skipping -->
        <control type="group">
            <right>150</right>
            <top>795</top>
            <width>140</width>
            <height>60</height>
            <visible>!Window.IsVisible(VideoBookmarks) + !Window.IsVisible(DialogSettings.xml)</visible>
            <visible>[Player.DisplayAfterSeek + Integer.IsGreater(Player.ChapterCount,0)] | Integer.IsGreater(MusicPlayer.PlaylistLength,0) | !String.IsEmpty(Player.SeekStepSize)</visible>

            <!-- Background -->
            <control type="image">
                <width>140</width>
                <height>60</height>
                <texture colordiffuse="$VAR[OverlayColor]">dialogs/Background.png</texture>
            </control>

            <!-- Status -->
            <control type="label">
                <width>140</width>
                <height>60</height>
                <font>Font27</font>
                <align>center</align>
                <label>[B]$INFO[Player.Chapter,(,/]$INFO[Player.ChapterCount,,)][/B][B]$INFO[MusicPlayer.PlaylistPosition,(,/]$INFO[MusicPlayer.PlaylistLength,,)][/B]</label>
                <textcolor>DialogColor2</textcolor>
                <visible>!Window.IsVisible(visualisation) + String.IsEmpty(Player.SeekStepSize)</visible>
            </control>

            <!-- Status -->
            <control type="label">
                <width>140</width>
                <height>60</height>
                <font>Font27</font>
                <align>center</align>
                <label>[B]$INFO[MusicPlayer.PlaylistPosition,(,/]$INFO[MusicPlayer.PlaylistLength,,)][/B]</label>
                <textcolor>DialogColor2</textcolor>
                <visible>Window.IsVisible(visualisation) + String.IsEmpty(Player.SeekStepSize)</visible>
            </control>

            <!-- Status -->
            <control type="label">
                <width>140</width>
                <height>60</height>
                <font>Font27</font>
                <align>center</align>
                <visible>!String.IsEmpty(Player.SeekStepSize)</visible>
                <label>$INFO[Player.SeekStepSize]</label>
                <textcolor>DialogColor2</textcolor>
            </control>

        </control>

        <!-- Progress -->
        <control type="group">
            <visible>!Window.IsVisible(DialogSettings.xml)</visible>
            <left>150</left>
            <top>870</top>
            <width>1620</width>
            <height>60</height>
            
            <animation type="WindowOpen" condition="!Window.IsActive(seekbar) + !Window.IsActive(fullscreeninfo)">
                <effect type="zoom" start="90" end="100" center="auto" tween="back" easing="out" time="200"/>
                <effect type="fade" start="0" end="100" time="200"/>
            </animation>
            <animation type="WindowClose" condition="!Window.IsActive(seekbar) + !Window.IsActive(fullscreeninfo)">
                <effect type="zoom" start="100" end="90" center="auto" easing="in" time="200"/>
                <effect type="fade" start="100" end="0" time="200"/>
            </animation>

            <!-- Background -->
            <control type="image">
                <width>1620</width>
                <height>60</height>
                <texture colordiffuse="$VAR[OverlayColor]">dialogs/Background.png</texture>
            </control>

            <!--  Current position/Time remaining -->
            <control type="label">
                <left>20</left>
                <width>260</width>
                <height>60</height>
                <font>Font27</font>
                <textcolor>DialogColor2</textcolor>
                <label>$INFO[Player.Time] / $INFO[Player.Duration]</label>
            </control>

            <control type="slider" id="9000">
                <left>280</left>
                <top>20</top>
                <width>920</width>
                <height>20</height>
                <texturesliderbar border="10,0,10,0">osd/OSDSliderBack.png</texturesliderbar>
                <textureslidernib border="10,0,10,0">osd/OSDSliderNib.png</textureslidernib>
                <textureslidernibfocus border="10,0,10,0">osd/OSDSliderNib.png</textureslidernibfocus>
            </control>
            
            <!-- Seek slider
            <control type="slider">
                <left>280</left>
                <top>20</top>
                <width>920</width>
                <height>20</height>
                <texturesliderbar />
                <textureslidernib />
                <textureslidernibfocus />
                <action>seek</action>
            </control>
            -->

            <!--  Progress bar -->
            <control type="progress">
                <left>280</left>
                <top>20</top>
                <width>920</width>
                <height>20</height>
                <info>Player.Progress</info>
                <texturebg border="2" colordiffuse="DialogColor2">osd/OSDProgressBack.png</texturebg>
                <lefttexture>-</lefttexture>
                <midtexture border="2" colordiffuse="DialogColor1">osd/OSDProgressBar.png</midtexture>
                <righttexture>-</righttexture>
                <overlaytexture>-</overlaytexture>
            </control>

            <!--  Cache bar -->
            <control type="progress">
                <left>280</left>
                <top>20</top>
                <width>920</width>
                <height>20</height>
                <info>Player.ProgressCache</info>
                <texturebg colordiffuse="DialogColor2" border="2">osd/OSDProgressBack.png</texturebg>
                <lefttexture>-</lefttexture>
                <midtexture colordiffuse="OSDCache" border="2">osd/OSDProgressBar.png</midtexture>
                <righttexture>-</righttexture>
                <overlaytexture>-</overlaytexture>
            </control>

            <!-- Current Time/End Time -->
            <control type="label">
                <left>1001</left>
                <width>600</width>
                <height>60</height>
                <align>right</align>
                <font>Font27</font>
                <textcolor>DialogColor2</textcolor>
                <label>$INFO[System.Time,$LOCALIZE[142] , / ]$INFO[Player.FinishTime,$LOCALIZE[19081] ]</label>
            </control>

        </control>

        <control type="group">
            <left>150</left>
            <top>945</top>
            <width>1620</width>
            <height>60</height>
            <visible>!Window.IsVisible(VideoBookmarks) + !Window.IsVisible(DialogSettings.xml)</visible>
            <animation type="WindowOpen" condition="!Window.IsActive(seekbar) + !Window.IsActive(fullscreeninfo)">
                <effect type="zoom" start="90" end="100" center="auto" tween="back" easing="out" time="200"/>
                <effect type="fade" start="0" end="100" time="200"/>
            </animation>
            <animation type="WindowClose" condition="!Window.IsActive(seekbar) + !Window.IsActive(fullscreeninfo)">
                <effect type="zoom" start="100" end="90" center="auto" easing="in" time="200"/>
                <effect type="fade" start="100" end="0" time="200"/>
            </animation>

            <!-- Background -->
            <control type="image">
                <width>1620</width>
                <height>60</height>
                <texture colordiffuse="$VAR[OverlayColor]">dialogs/Background.png</texture>
            </control>

            <!-- Controls -->
            <control type="grouplist">
                <width>540</width>
                <height>60</height>
                <itemgap>0</itemgap>
                <onleft>20</onleft>
                <onright>12</onright>
                <onup>30</onup>
                <ondown>30</ondown>
                <orientation>horizontal</orientation>

                <!-- Spacer -->
                <control type="image" id="40">
                    <left>0</left>
                    <top>0</top>
                    <width>7</width>
                    <height>60</height>
                    <texture>transparent.png</texture>
                </control>

                <!-- Skip Back -->
                <control type="button" id="1">
                    <width>9</width>
                    <height>60</height>
                    <onleft>2</onleft>
                    <onright>4</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDTrickBackwardEnd.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDTrickBackwardEnd.png</texturenofocus>
                    <onclick>PlayerControl(Previous)</onclick>
                    <visible>!VideoPlayer.Content(LiveTV)</visible>
                </control>
                <!-- Rewind -->
                <control type="togglebutton" id="2">
                    <width>18</width>
                    <height>60</height>
                    <onleft>8</onleft>
                    <onright>10</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDTrickBackward.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDTrickBackward.png</texturenofocus>
                    <alttexturefocus colordiffuse="DialogColor1">osd/OSDTrickBackward.png</alttexturefocus>
                    <alttexturenofocus colordiffuse="DialogColor1">osd/OSDTrickBackward.png</alttexturenofocus>
                    <usealttexture>Control.HasFocus(1)</usealttexture>
                    <onclick>PlayerControl(Rewind)</onclick>
                    <visible>Player.SeekEnabled</visible>
                </control>
                <!-- Tempo Down -->
                <control type="togglebutton" id="3">
                    <width>18</width>
                    <height>60</height>
                    <onleft>8</onleft>
                    <onright>10</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDTrickBackward.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDTrickBackward.png</texturenofocus>
                    <alttexturefocus colordiffuse="DialogColor1">osd/OSDTrickBackward.png</alttexturefocus>
                    <alttexturenofocus colordiffuse="DialogColor1">osd/OSDTrickBackward.png</alttexturenofocus>
                    <usealttexture>Control.HasFocus(1) | Control.HasFocus(2)</usealttexture>
                    <onclick>PlayerControl(TempoDown)</onclick>
                    <visible>Player.SeekEnabled</visible>
                    <enable>Player.TempoEnabled</enable>
                </control>

                <!-- Spacer -->
                <control type="image" id="41">
                    <left>0</left>
                    <top>0</top>
                    <width>7</width>
                    <height>60</height>
                    <texture>transparent.png</texture>
                </control>

                <!-- Up -->
                <control type="button" id="4">
                    <width>60</width>
                    <height>60</height>
                    <onleft>4</onleft>
                    <onright>6</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDUpNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDUpNF.png</texturenofocus>
                    <onclick>PlayerControl(Previous)</onclick>
                    <visible>VideoPlayer.Content(LiveTV)</visible>
                </control>

                <!-- Play/Pause -->
                <include condition="Player.PauseEnabled">OSDPlayStopButtons</include>
                <!-- Stop -->
                <include condition="!Player.PauseEnabled">OSDStopButton</include>

                <!-- Down -->
                <control type="button" id="7">
                    <width>60</width>
                    <height>60</height>
                    <onleft>5</onleft>
                    <onright>7</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDDownNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDDownNF.png</texturenofocus>
                    <onclick>PlayerControl(Next)</onclick>
                    <visible>VideoPlayer.Content(LiveTV)</visible>
                </control>

                <!-- Spacer -->
                <control type="image" id="42">
                    <left>0</left>
                    <top>0</top>
                    <width>7</width>
                    <height>60</height>
                    <texture>transparent.png</texture>
                </control>

                <!-- Tempo Up -->
                <control type="togglebutton" id="8">
                    <width>18</width>
                    <height>60</height>
                    <onleft>8</onleft>
                    <onright>10</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDTrickForward.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDTrickForward.png</texturenofocus>
                    <alttexturefocus colordiffuse="DialogColor1">osd/OSDTrickForward.png</alttexturefocus>
                    <alttexturenofocus colordiffuse="DialogColor1">osd/OSDTrickForward.png</alttexturenofocus>
                    <usealttexture>Control.HasFocus(9) | Control.HasFocus(10)</usealttexture>
                    <onclick>PlayerControl(TempoUp)</onclick>
                    <visible>Player.SeekEnabled</visible>
                    <enable>Player.TempoEnabled</enable>
                </control>
                <!-- Fast Forward -->
                <control type="togglebutton" id="9">
                    <width>18</width>
                    <height>60</height>
                    <onleft>8</onleft>
                    <onright>10</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDTrickForward.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDTrickForward.png</texturenofocus>
                    <alttexturefocus colordiffuse="DialogColor1">osd/OSDTrickForward.png</alttexturefocus>
                    <alttexturenofocus colordiffuse="DialogColor1">osd/OSDTrickForward.png</alttexturenofocus>
                    <usealttexture>Control.HasFocus(10)</usealttexture>
                    <onclick>PlayerControl(Forward)</onclick>
                    <visible>Player.SeekEnabled</visible>
                </control>
                <!-- Next -->
                <control type="button" id="10">
                    <width>9</width>
                    <height>60</height>
                    <onleft>7</onleft>
                    <onright>9</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDTrickForwardEnd.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDTrickForwardEnd.png</texturenofocus>
                    <onclick>PlayerControl(Next)</onclick>
                    <visible>!VideoPlayer.Content(LiveTV)</visible>
                </control>

                <!-- Spacer -->
                <control type="image" id="43">
                    <left>0</left>
                    <top>0</top>
                    <width>7</width>
                    <height>60</height>
                    <texture>transparent.png</texture>
                </control>

                <!-- Record -->
                <control type="togglebutton" id="11">
                    <width>60</width>
                    <height>60</height>
                    <onleft>8</onleft>
                    <onright>10</onright>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDRecordOffNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDRecordOffNF.png</texturenofocus>
                    <alttexturefocus colordiffuse="DialogColor1">osd/OSDRecordOnNF.png</alttexturefocus>
                    <alttexturenofocus colordiffuse="DialogColor2">osd/OSDRecordOnNF.png</alttexturenofocus>
                    <usealttexture>Player.Recording</usealttexture>
                    <onclick>PlayerControl(Record)</onclick>
                    <visible>Player.CanRecord</visible>
                </control>

            </control>

            <!-- Options -->
            <control type="grouplist" id="30">
                <right>0</right>
                <width>360</width>
                <height>60</height>
                <align>right</align>
                <itemgap>0</itemgap>
                <onleft>11</onleft>
                <onright>1</onright>
                <onup>5</onup>
                <ondown>5</ondown>
                <orientation>horizontal</orientation>

                <!-- 3D mode -->
                <control type="button" id="12">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSD3DNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSD3DNF.png</texturenofocus>
                    <onclick>StereoMode</onclick>
                    <visible>VideoPlayer.IsStereoscopic</visible>
                </control>
                <!-- Video Settings -->
                <control type="button" id="13">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDVideoNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDVideoNF.png</texturenofocus>
                    <onclick>ActivateWindow(123)</onclick>
                </control>
                <!-- Audio Settings -->
                <control type="button" id="14">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDAudioNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDAudioNF.png</texturenofocus>
                    <onclick>ActivateWindow(124)</onclick>
                </control>
                <!-- Bookmarks -->
                <control type="button" id="15">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDBookmarksNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDBookmarksNF.png</texturenofocus>
                    <onclick>ActivateWindow(125)</onclick>
                    <visible>!VideoPlayer.Content(LiveTV)</visible>
                </control>
                <!-- Subtitles -->
                <control type="button" id="16">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDSubtitlesNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDSubtitlesNF.png</texturenofocus>
                    <onclick>Close</onclick>
                    <onclick>ActivateWindow(SubtitleSearch)</onclick>
                    <visible>!VideoPlayer.Content(LiveTV)</visible>
                </control>
                <!-- Channels -->
                <control type="button" id="17">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDChannelNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDChannelNF.png</texturenofocus>
                    <onclick>ActivateWindow(PVROSDChannels)</onclick>
                    <visible>VideoPlayer.Content(LiveTV)</visible>
                </control>
                <!-- Channel EPG -->
                <control type="button" id="18">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDEPGNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDEPGNF.png</texturenofocus>
                    <onclick>ActivateWindow(PVROSDGuide)</onclick>
                    <visible>VideoPlayer.Content(LiveTV)</visible>
                </control>
                <!-- Teletext -->
                <control type="button" id="19">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDTextNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDTextNF.png</texturenofocus>
                    <onclick>ActivateWindow(Teletext)</onclick>
                    <visible>VideoPlayer.Content(LiveTV)</visible>
                </control>
                <!-- DVD menu -->
                <control type="button" id="20">
                    <width>60</width>
                    <height>60</height>
                    <texturefocus colordiffuse="DialogColor1">osd/OSDDvdNF.png</texturefocus>
                    <texturenofocus colordiffuse="DialogColor2">osd/OSDDvdNF.png</texturenofocus>
                    <onclick>PlayerControl(ShowVideoMenu)</onclick>
                    <visible>VideoPlayer.HasMenu</visible>
                </control>

            </control>

        </control>

    </controls>

</window>

My log file says the control 9000 doesn't exist ...
Reply
#6
This would be better in the addon development section. I'll move it there.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#7
Oups, sorry if i was in the wrong section ! Maybe someone will be able to help me here ! thanks
Reply
#8
I have been able to come close to my needs, now i need to detect controlSlider event. Anyone could help me?
Reply
#9
Nobody know how to handle change of slider ?
Reply

Logout Mark Read Team Forum Stats Members Help
Control event from addon0