2013-06-10, 00:16
I am writing a script that will play a couple of random trailers before playing a movie. I had planned to pick a couple of trailers from a dynamically generated list and then add them to a playlist and then add the selected movie to the end of the playlist. I am unable to figure out how to make a playlist with a script, or if this is even possible. Alternatively, I can make a list of trailers (using a python data structure) and just play them from that list. Unfortunately, when I do that I can't figure out how to wait on one trailer to finish before the other one starts. The result is that the last trailer in the list is the one that gets played. Also, with this method, I don't think I can easily skip to the next trailer.
Here is my code to illustrate what I am trying to do...
Thanks,
Andy
Here is my code to illustrate what I am trying to do...
Code:
MOVIE_PATH = 'D:/Movies/'
for root, dirs, files in os.walk(MOVIE_PATH):
for directory in dirs:
dirstring = MOVIE_PATH + directory
for files in os.listdir(dirstring):
if "-trailer" in files:
trailer = dirstring + '/' + files
xbmc.executebuiltin('XBMC.PlayMedia(' + trailer + ')')
Thanks,
Andy