Kodi Community Forum
automatic playlist startup - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: automatic playlist startup (/showthread.php?tid=2264)

Pages: 1 2 3


- xsintill - 2004-03-20

a variation on a script just released by alx5962 is to play a playlist


Quote:import xbmc

pls = xbmc.playlist(0)                                       ##0 should be music playlist and 2 should be video playlist... not tested      
pls.load("smb://user:password@/idm/test.m3u")   ## load non xbmc playlist into xbmc's playlist  m3u and pls work
xbmc.player().play(pls)                                    ## play the playlist



- Vortex - 2004-03-20

it works! excellent! thank you for that!

i added a pls.shuffle() before the play line to have nice random songs on boot.

i didn't know if that would work, or if the command existed, but it did lol.


- gameloader - 2004-03-21

this is an awsome idea.... can you possibly post a link were i can download the script and how do i use it?


- Nickman - 2004-03-21

(gameloader @ mar. 21 2004,09:15 Wrote:this is an awsome idea.... can you possibly post a link were i can download the script and how do i use it?

alx5962 python scripts

download copy to your xbmc/scripts folder and in the menu settings/scripts select the script.


- xsintill - 2004-03-21

or you can create the files yourself.. they are normal textfiles but with a .py extension. they should be put in the scripts directory in xbmc's 'home' directory.

one file should be named autoexec.py
and have the following code in it:
Quote:import xbmc

xbmc.executescript('q:\\scripts\\autoplay.py')

and the other one should be named autoplay.py
and have the following code in it:
Quote:
import xbmc

pls = xbmc.playlist(0)                                       ##0 should be music playlist and 2 should be video playlist... not tested      
pls.load("smb://user:password@/idm/test.m3u")   ## load non xbmc playlist into xbmc's playlist  m3u and pls work
pls.shuffle()                                                   ## delete this line if you don't want random songs to be played from your given playlist
xbmc.player().play(pls)                                    ## play the playlist



- Zeba - 2004-04-17

hi, can someone help me out. i'm new to these python scripts.

i can't get the playlist to play..
i didn't quite understand " ## load non!? xbmc playlist into xbmc's playlist  m3u and pls work "
i made the playlist with xbmc? wrong?

then i edited the script in autoplay.py to:
Quote:pls.load("f://apps/xbmc/albums/playlists/pl.m3u")  

so is there something wrong with that?

i have a xbmc from 2004-04-13
i have also extracted the python.rar into the /python dir. and i've put the .py files in the /scrpits dir.


thanx!


- xsintill - 2004-04-17

zeba you should change it to the following:
Quote:pls.load("q:\\albums\\playlists\\pl.m3u")
q: stands for the homedirectory of xbmc.
if you have more than 1 xbmc locations on your drive and want to access a playlist created with a different xbmc than where you are executing this script from use the following:
Quote:pls.load("f:\\apps\\xbmc\\albums\\playlists\\pl.m3u")

when using filenames locally you should use this slash \ instead of /
because slashes within strings are escape codes you have to put another one behind it


- SpaceFrog - 2004-04-29

forkin sweet mayte!!!!

this is what i've wanted for about 3 months!!

i asked around on forums (can't remember if i posted here or not) but didnt get anything helpful at all.

this works pretty damn good, it's for my car mp3 player and, most of the time i can't be stuffed fiddling with the xbox remote to load up a song, i just want to turn on my car and xbox and go.

i'm not sure if i will need to do this but.... does any1 know how to go about making it play a random playlist?

right now i've got mine set to shuffle the big playlist of all my songs on the xbox b4 playing. but it mixes genre's too much i reckon, was thinking of making a few playlists for different genre's


- xsintill - 2004-04-29

@SpaceFrog if i understand you correctly you have a collection of playlists and you want xbmc to pick a random playlist. do the following:


Quote:import xbmc ,xbmcgui,random

dic={1:"playlist1.m3u",2:"playlist2.pls",3:"playlist3.m3u"}
rnd=random.randint(1,len(dic))
pls = xbmc.playlist(0)                                      ## initialize music playlist 0 should be music where 2 should be video
pls.load(dic[rnd])                                          ## load non xbmc playlist into xbmc's playlist  m3u and pls are tested and work
xbmc.player().play(pls)                                     ## play the playlist
if you want more playlists just add another pair to dic but make sure you don't create gaps so the next new pair should be
Quote: , 4:"playlistfilename"
and not
Quote:,5:"playlistfilename"



- NizZ8 - 2004-05-05

sweeet!!!! i hear ya on this one spacefrog.. very happy to see this util!. do you have some pix of the setup in your car/truck? i'd be interested to see how your setup looks!


- NizZ8 - 2004-05-14

q for you guys, what would be the best way to impliment the following:

1) play a startup intro song
2) when that file is done playing -> load playlist
--
3) shuffle playlist
4) play a song from the playlist

so parts 3-4 are taken care of already using this script.. i wasn't sure how to impliment steps 1 and 2..

i tried the wait() function for the lenght of the startup file, but couldn't get it to work.

any ideas?

thanks!
-n8


- NizZ8 - 2004-05-16

i figured it out.. i flipped around the code and now it works great!

Quote:import xbmc

# by alx5962
# version 1.0

pls = xbmc.playlist(0)                                      ##0 should be music playlist and 2 should be video playlist... not tested      
pls.load("q:\\albums\\playlists\\startup.m3u")      ## load non xbmc playlist into xbmc's playlist  m3u and pls work
pls.shuffle()                                               ## delete this line if you don't want random songs to be played from your given playlist
xbmc.player().play(pls)                                     ## play the playlist
file = 'q:\\scripts\\startup.mp3'
xbmc.player().play(file)

so now my truck on startup:
1) plays the startup.mp3 file
2) loads the playlist
3) shuffles
4) plays a song

cool beans!


- Kudos - 2004-05-25

i was trying to mod the original script also, glad to see you pulled it off, saves me some time :d

/kudos


- kazor - 2004-06-03

make your xbox auto-powerup !

regarding the auto startup scripts i have put the same
scripts in my xbox with the purpose to startup & start
playing mp3's in my car. (stuff screwin with the menus
everytime you start the car)

thanks guys for the script tips, mine now works great
too now i worked out the python code.

i run my xbox on a 300w peak pure sine wave inverter
(it draws about 6amps at 12v). its from jaycar in
australia and has no fan so it's sealed , quiet and doesn't
seem to get warm either although put it in a place that
the heatsink can get some sort of convection.

but to get to the main point regarding the auto-poweron, if
you connect a 33uf electrolytic capacitor across the power
button on the front of the xbox the characteristic of the
capacitor simulates a power button push nicely.

just make sure you check the polarity on the button
with a multi meter even though it's unlikely to damage the
capacitor at 3.3 odd volts, it'll save you having future
problems scredded paper style...:p.

if you then put a push button in parallel with the capacitor
as well (assuming you run a wire to the an accessable
location in the car) you can also re-power should the xbox
crash.

hope this helps, thanks guys for xbmc - awesome effort !

cheers kazor


- NizZ8 - 2004-06-06

(kudos @ may 25 2004,16:06 Wrote:i was trying to mod the original script also, glad to see you pulled it off, saves me some time :d

/kudos
happy to help out!

kazor:
cool stuff! i currently just power my xbox on using the xir kit (dvd remote) that greengiant sells. i pull my xbox out of my truck on a regular basis, and wanted to keep the connections between my xbox-> truck (video/power/controllers etc..) to a minimum.