2010-02-07, 19:25
This simple script automatically plays all videofiles in a directory. The path of the directory can be set in the scriptfile.
I was in need of such a script myself, so decided to learn some python and script it myself.
The script also shuffles the order of the videos, so the order of the videofiles is different every time. (you can turn this option off by adding a # in front of the videoList.shuffle() command)
It also puts all of your videos on repeat, so when the last video has been played; it starts over again. (turn this option off by adding a # in front of the xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)") command)
Very simple script, but I noticed some requests for a function like this in the past.
Copy the above code, paste it in notepad and save it as autoplaydir.py (or something similar). Put the file in your xbmc/scripts/ directory.
Add the script to your autoexec.py file to make it automatically play your videos at startup.
Have fun with it
I was in need of such a script myself, so decided to learn some python and script it myself.
The script also shuffles the order of the videos, so the order of the videofiles is different every time. (you can turn this option off by adding a # in front of the videoList.shuffle() command)
It also puts all of your videos on repeat, so when the last video has been played; it starts over again. (turn this option off by adding a # in front of the xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)") command)
Very simple script, but I noticed some requests for a function like this in the past.
Code:
# Autoplay videodirectory
import os, xbmc
# set path to dir you want to play
path="E:\\videos"
dirList=os.listdir(path)
videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
videoList.clear()
for fname in dirList:
videoList.add(path + "\\" + fname)
# shuffle playlist
videoList.shuffle()
# put playlist on repeat
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)")
# play playlist
xbmc.Player().play(videoList)
Copy the above code, paste it in notepad and save it as autoplaydir.py (or something similar). Put the file in your xbmc/scripts/ directory.
Add the script to your autoexec.py file to make it automatically play your videos at startup.
Have fun with it
