autoexec.py troubles...
#1
i'm trying to play a playlist and start the visualizer automatically at startup. (my 2-year-old and the dog both like to fiddle with/chew on controllers, so i need to avoid bringing them out if possible.) i'm using autoexec.py to execute two sub-scripts.

problem is, the scripts seem to execute about half the time. sometimes the playlist starts, sometimes it won't. if i wait a minute and go to the scripts menu, i can start the playlist player and show visualizer scripts individually, and then autoexec.py usually works, but it rarely does at startup.

the files in the playlist are on a samba share. could that be part of the problem?

here's the listing for autoexec.py:
Quote:#execute targeted script at startup.
import xbmc
xbmc.executescript('e:\\applications\\xbmc\\scripts\\play_playlist.py')
xbmc.executescript('e:\\applications\\xbmc\\scripts\\show_visualizer.py')

play_playlist.py:
Quote:import xbmc, xbmcgui

#load playlist from file.
playlist = xbmc.playlist(0)
playlist.load('e:\\applications\\xbmc\\albums\\playlists\\5 star electronic music.m3u')

#shuffle playlist.
playlist.shuffle()

#play playlist.
xbmc.player().play(playlist)

show_visualizer.py:
Quote:import xbmc, xbmcgui

#window ids are from key.h in xbmc source.
window_invalid = 9999
window_home = 10000
#snip
window_visualisation = 12006
#snip

window = xbmcgui.window(window_visualisation)
window.show()

i'm using the 06-29-04 xbmc release (v 1.0).

suggestions? i'll be able to use xbmc twice as often if all i have to do is hit the power switch.
Reply
#2
it's a know problem for me that executing 2 scripts at the same time can give you some problems.
try adding a pause of a few seconds between each of the xbmc.executescript command's and see if that helps

i believe it was something with wait(2000)
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
(darkie @ july 05 2004,15:13 Wrote:it's a know problem for me that executing 2 scripts at the same time can give you some problems.
try adding a pause of a few seconds between each of the xbmc.executescript command's and see if that helps

i believe it was something with wait(2000)
time.sleep()? played around with it, and finally discovered that sleeping for as little as 0.1 seconds between play_playlist.py and show_visualizer.py took care of my visualizer problems. thanks!

:fixed:

my next problem was getting the playlist to play - it turns out it was the samba connection that was giving me problems. i wound up having it loop and sleep until a file out on a samba share was found, which told me that the samba connection was up and i could attempt to run my playlist.

my revised autoexec.py:

Quote:#execute targeted script at startup.
import xbmc, time
xbmc.executescript('e:\\applications\\xbmc\\scripts\\wait_for_file.py')
xbmc.executescript('e:\\applications\\xbmc\\scripts\\play_playlist.py')
time.sleep(0.1)
xbmc.executescript('e:\\applications\\xbmc\\scripts\\show_visualizer.py')
wait_for_file.py:

Quote:#wait for file to appear before exiting (use to delay running of other scripts).

import os, time

#set this to the file you want to watch for.
file = 'smb://userid:password@host/text/playlists/5 star electronic music.m3u'

#set time out value.
seconds_until_time_out = 60

#loop until the samba share is found, or we time out.
while (not os.path.exists(file)) and seconds_until_time_out > 1:
time.sleep(1)
seconds_until_time_out = seconds_until_time_out - 1
kludgy, but it works like a charm. :kickass:
Reply

Logout Mark Read Team Forum Stats Members Help
autoexec.py troubles...0