Kodi Community Forum

Full Version: Running a script at movie startup?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there a way to run a AppleScript or shell when movies/music are selected to be played.

Any ideas are much appreciated
Thanks,
ADAIR
No simple way. I can't remember if XBMC sends a JSON notification when playback starts.

JR
I'm trying to use this to create a python script.

However, when I run it, it gets to "import xbmc,xbmcgui" and I get the error "ImportError: No module named xbmc"

Any ideas?
Thanks.
Cool, I didn't know you could do that :-)

Anyhow, I gave this a quick try and it works if you run it from autoexec.py. This, of course, is exactly the abuse of the autoexec.py that caused the devs to add service add-ons in Eden! Still, I suppose it's the only way to achieve this in v10.1.

How are you trying to run the script? If you just try to run it in Python then it will fail because the standard Python setup has no xbmc or xbmcgui libraries. You need to find some way to run this in XBMC. One way is to create a file called autoexec.py in your userdata folder and put the code in there. XBMC runs the autoexec.py script when it starts. I've just done this and indeed it works.

JR
You can easily make a service out of it in Eden (not sure about Dharma)

just make an addon.xml
and add this
Code:
<extension point="xbmc.service" library="light.py" start="startup|login"/>

We use it do script runs on startup or on set times.
Example code
https://github.com/paddycarey/script.art.../addon.xml
Thanks guys. I'll give it a try.
Martijn Wrote:You can easily make a service out of it in Eden (not sure about Dharma)

just make an addon.xml
and add this
Code:
<extension point="xbmc.service" library="light.py" start="startup|login"/>

We use it do script runs on startup or on set times.
Example code
https://github.com/paddycarey/script.art.../addon.xml

How should I add the add-on when finished? Should I just drop it in the addon folder or should I install from zip file?

I tried install from zip and it says incorrect folder structure. I'm not sure what I'm doing wrong.

Any ideas?
ADAIR Wrote:How should I add the add-on when finished? Should I just drop it in the addon folder or should I install from zip file?

I tried install from zip and it says incorrect folder structure. I'm not sure what I'm doing wrong.

Any ideas?

remember that you don't need all that we put in Wink

create yourself a sub folder for your add-on next to the rest of to the rest of the add-ons.
The folder name needs to be the exact same name as the 'id' in addon.xml

place your files there to test it out. Just look at other script how other scripts are made
So inside addons I have a folder called script.jack and inside that I have addon.xml and audio.py

But nothing is showing up in XBMC under addons.

I did get this to work using the autoexec.py method.

Also is there something like xbmc.Player().isPlayingVideo() for music?
I tried replacing video with Music and Audio but it didn't work.

Thanks for all the help so far.
ADAIR Wrote:So inside addons I have a folder called script.jack and inside that I have addon.xml and audio.py

But nothing is showing up in XBMC under addons.

I did get this to work using the autoexec.py method.

Also is there something like xbmc.Player().isPlayingVideo() for music?
I tried replacing video with Music and Audio but it didn't work.

Thanks for all the help so far.

That's because yours is a script not an add-on so that's why it doesn't show up.

xbmc.Player().isPlayingAudio()
or
xbmc.Player().isPlaying()
for everything.

Remember that when plaing music files the xbmc.Player().isPlayingAudio() will change state for a brief moment so it's best to put in a time.sleep(xx) before really doing any action
Py-doc:
http://passion-xbmc.org/gros_fichiers/XB...tml#Player
Ok. I have it all working except a minor issue. How can I get it to run the script only when I play the first song and not every time I skip to a new track?
ADAIR Wrote:Ok. I have it all working except a minor issue. How can I get it to run the script only when I play the first song and not every time I skip to a new track?

paste your code on http://paste.ubuntu.com and post that link here and i'll have a look
Martijn Wrote:paste your code on http://paste.ubuntu.com and post that link here and i'll have a look

Ok. I've been posting with my iPhone since my internet is down. So I'll have to wait.
ADAIR Wrote:Ok. I've been posting with my iPhone since my internet is down. So I'll have to wait.

Best do a PM notifying me that pkaced the script here. One question, are you running dharma or eden?
Martijn Wrote:Best do a PM notifying me that pkaced the script here. One question, are you running dharma or eden?

pre-Eden on Mac OSX 10.7.1
Pages: 1 2