Solved run onclick instead of onAVStarted () ?
#1
hi, I'd like to run some Python scripts at the beginning of a video (movie/tv show).

Can I use XML only? Something like <onclick> or <onfocus>

or do I have to use xbmc.Monitor() ?

I'd love a solution without monitoring since the script needs to run at the beginning (00:00:00) of a movie/tv show.

Your suggestions are very much appreciated!
Reply
#2
Put it in the <onload> of VideoFullScreen.xml

xml:
<?xml version="1.0" encoding="UTF-8"?>
<window>
    <onload>RunScript(script.myscript)</onload>
    <controls>
    </controls>
</window>
Reply
#3
(2023-05-14, 13:26)roidy Wrote: Put it in the <onload> of VideoFullScreen.xml

xml:
<?xml version="1.0" encoding="UTF-8"?>
<window>
    <onload>RunScript(script.myscript)</onload>
    <controls>
    </controls>
</window>
ah of course! Thank you! Smile

Another thing, I realised I have a different scenario where I need to run a script but this time it's when a list is focused.

So how do I set the condition now?  Huh
Reply
#4
Just the list being focused or for every item in the list?

If it's just the initial focus of the list then you can add <onfocus> directly to lists just like you would <onclick> or <onup> etc...

xml:
<control type="list">
  
  <onfocus>RunScript(script.myscript)</onfocus>

  <itemlayout .......>
  </itemlayout>
  <focusedlayout ......>
  </focusedlayout>
</control>

However if you need it to run everytime a different list item is focused then you'll need to use the hidden button trick:-

xml:
<control type="list">
  <itemlayout .......>
  </itemlayout>
  <focusedlayout ......>
    <control type="button">
      <visible>false</visible>
      <onfocus>RunScript(script.myscript)</onfocus>
    </control>
  </focusedlayout>
</control>
Reply
#5
(2023-05-14, 14:58)roidy Wrote: Just the list being focused or for every item in the list?

If it's just the initial focus of the list then you can add <onfocus> directly to lists just like you would <onclick> or <onup> etc...

xml:
<control type="list">
  
  <onfocus>RunScript(script.myscript)</onfocus>

  <itemlayout .......>
  </itemlayout>
  <focusedlayout ......>
  </focusedlayout>
</control>

However if you need it to run everytime a different list item is focused then you'll need to use the hidden button trick:-

xml:
<control type="list">
  <itemlayout .......>
  </itemlayout>
  <focusedlayout ......>
    <control type="button">
      <visible>false</visible>
      <onfocus>RunScript(script.myscript)</onfocus>
    </control>
  </focusedlayout>
</control>
Yes, the hidden button trick worked too! Awesome, thank you so much for your help!!
Reply

Logout Mark Read Team Forum Stats Members Help
run onclick instead of onAVStarted () ?0