PDA

View Full Version : automatic playlist startup


xsintill
2004-03-20, 01:25
a variation on a script just released by alx5962 is to play a playlist


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, 04:04
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, 11:15
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, 11:43
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 (http://www.gueux.net/xbmc-scripts/index.html)

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

xsintill
2004-03-21, 12:02
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:
import xbmc

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


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

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, 08:54
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:
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, 10:58
zeba you should change it to the following:
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:
pls.load("f:\\apps\\xbmc\\albums\\playlists\\pl.m3 u")

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, 17:21
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, 21:00
@spacefrog if i understand you correctly you have a collection of playlists and you want xbmc to pick a random playlist. do the following:


import xbmc ,xbmcgui,random

dic={1:"playlist1.m3u",2:"playlist2.pls",3:"playli st3.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
, 4:"playlistfilename" and not,5:"playlistfilename"

NizZ8
2004-05-05, 02:41
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, 02:59
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, 11:17
i figured it out.. i flipped around the code and now it works great!

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, 18:06
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, 14:51
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, 04:18
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.

j0ly
2004-07-14, 02:56
awesome, this works great for the needs i have in my nightclub, but now i want to do something a little differnt, basically heres what im looking for:

i have a network within the club, with a server in my office that serves 1 xbox videos for display on the tv, now my dj's dont show up to begin playing music till around 9:30pm at night, and the club opens at 7.

i have a ton of mp3s that we did from taking all of our music and encoding (our club has actually been checked numerous times for legal music (not burned), so to be legit we encoded all our music) what i want to do is simplify everything, so im going to put another xbox in the dj both and run the audio ports into my mixer, basically i want it this xbox to do is check the system date, and play a playlist according to that.

so lemme give you an example:

its wednessday night, our hiphop urban night, i come in, turn everything on, turn on the xbox and the system boots in to mediacenter, runs a autoexec script, that run another script that checks the system time, if day = wednessday it loads wednessday.plu, randomizes it, begins playing it and switches to visuals.

thursday, friday and saturday would be the same, but obviously the script would reconize a different day of the week and switch to load a different script (thursday: rock, friday: country and top40, saturday: everything)

possible?

Alexpoet
2004-07-14, 17:41
j0ly, i'm pretty sure this will do basically what you need. it could take some degree of modification, but it should get the first three letters of the day of the week from the xbox, and then play a playlist by the name of those three letters (like "wed.m3u" on wednesday).

import time, xbmc

day = time.ctime()[:3] # all values are the first three letters of the day: sun, mon, tue, wed, thu, fri, sat
pls = xbmc.playlist(0) ## 0 should be music playlist and 2 should be video playlist... not tested * * *

pls.load(day + ".m3u") ## load non xbmc playlist into xbmc's playlist *m3u and pls work
# remember to add a path as necessary; it can be local: pls.load("q:/music/" + day + ".m3u"),
# or smb network share: pls.load("smb://user:password@/" + day + ".m3u")

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

obviously, it's a modification of the same sort of playlist code earlier in this post. you would use the exact same autoexec script.

i don't have access to an xbox right now, so i can't guarantee time.ctime() will return the same information reliably on the xbox, but it should. i'll double-check that as soon as i get home.

pluto
2004-07-19, 15:47
someone knows after run the script how switches to visuals, or hide the information bar from home

mich24
2004-07-22, 13:55
hi!

does someone know how to randomly pick one of the playlists, without writing all of them
(i have a few hundreds, one for each album, so using the dic={1:"playlist1.m3u",2:"playlist2.pls",3:"playlist3.m3u"} is not possible)

thanks for any idea!

(actually the best (for me) would be to automaticly open a folder randomly choosen and read all the mp3 inside)

jcee
2004-10-08, 22:34
hi everybody.

want to share my experience and i do have a question in the end ;-)

auto-powerup:

i placed my xbox in the trunk of my car, replaced one controller port with a usb port and the installed the controller port in the dashboard. there i plugged-in the dvd-remote-ir-thing. the connection from trunk to dashboard is donw via a common usb extension cable :-)

i utilized a 150w 12/230 inverter which normally has got a switch to swich on/offf. i replaced this switch with a relay which is driven by the "remote signal" of the headunit. means when the headunit is switched on, the inverter starts working.

then the following mechanical arc / spring on the front power button of the xbox and sticked it with some glue.

-----------bbbbb -------------
xxx zzz xxx
x zzz x
xxxxxxxxxx
this spring (z) pushes the power button (b) all the time. actually this means when the inverters powers on the xbox starts working. if decide to power-off and repower the xbox i can just pull against the spring for a moment, so the power button is released.


works perfectly for about 7 month. :-)

after reading all this about the auto startup script i wonder if it possible to have resume and restart option.
i have not looked at the forum for a while. something new on this?
i do not have playlists.. :-(

MrT
2004-10-09, 10:36
does this work with the 1006 build?
i can't get it to work whatsooever.

iv copied the script from this tread (and modified it a bit). i put it in /f:/apps/xbmc/scripts/
and then run it manually.

the script looks like: (iv x'ed out the user/pw bit):

import xbmc
pls = xbmc.playlist(0)
pls.load("smb://xxx:xxx@10.0.0.2/mp3/test.m3u")
pls.shuffle()
xbmc.player().play(pls)

this does not work. noting happens when i start the script.

iv also tried :
pls.load("f://apps/xbmc/albums/playlists/test.m3u")
and
pls.load("q:\\albums\\playlists\\test.m3u")

(yes, i copied the .m3u file to those locations).
still nothing. is there a logfile i can check to see what goes wrong? or does anyone see the error?

MrT
2004-10-21, 18:01
forget the question above. i fucked around with the scripts and fixed it :)

jmarshall
2004-10-21, 18:41
looks like whatever editor you're using is screwing the file up.

it just needs to be a plain text file. use notepad.

then rename it to .py and ftp across to your xbox.

scarecrow420
2004-10-22, 22:56
hey guys ive written a script for car setups that starts playing as soon as the xbox comes on, and it has resume support, ie it remembers what song you last played and will load it up again next time you turn on the xbox.

it also creates a playlist of all the other files in the same directory as the resumed song

and failing being able to do that it will load a specified default playlist.


what i need to do to finish it off is to automatically switch to visuals when the playing starts... but i just cant see a way to do it! is there a way even to send keystrokes/button press messages to xbmc so i can send a display button command to it?

it's working very well in the car already, and this will just top it off if i can automate going to visuals too.

anyone have any ideas?

Threepwood
2004-10-27, 06:52
i can't really help you with figuring out how to get it to startup visualizations, but would love a copy of your script. been preping to do a car install and have been looking for a script to start up where it last left off.

darkie
2004-10-27, 13:29
what i need to do to finish it off is to automatically switch to visuals when the playing starts... but i just cant see a way to do it! *is there a way even to send keystrokes/button press messages to xbmc so i can send a display button command to it?
search for the file key.h in xbmc cvs. in there you will find a window id for the visualization screen (for example 10345)
now in your script you have to create a new window that uses the visualization screen

viswindow = xbmcgui.window(10345)
now you have access to that specific window and you will be able to show / close it with
viswindow.show()

Dogo
2004-10-28, 08:17
yes can you please post your script, even if not 100% complete and tested.

joe2000
2004-11-03, 00:49
thats exactly what i need for my car ! can yo post your script ? that would be great !

metalcoat
2004-11-17, 04:20
i tried learning python but i think it may be a bit too complicated since all i want is to know if its possible to make a script play a random mp3 file instead of a playlist from a network share or the hd

XbcSharpShooter
2004-11-18, 04:39
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:
import xbmc

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


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

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

i did that exact thing, with the 11-16 build, and nothing happens. i looked in log and nothing. i go to scripts folder, and click on it in xbmc, and it flashes running for a second, nothing happens.

xlinkx
2004-11-19, 07:21
hey guys ive written a script for car setups that starts playing as soon as the xbox comes on, and it has resume support, ie it remembers what song you last played and will load it up again next time you turn on the xbox.

it also creates a playlist of all the other files in the same directory as the resumed song

and failing being able to do that it will load a specified default playlist.


what i need to do to finish it off is to automatically switch to visuals when the playing starts... but i just cant see a way to do it! *is there a way even to send keystrokes/button press messages to xbmc so i can send a display button command to it?

it's working very well in the car already, and this will just top it off if i can automate going to visuals too.

anyone have any ideas?
can i get a copy of your script also?

psyke
2004-11-21, 09:52
is there a way to have this select a random web radio station if i give it a genre... such as "trance" and have it select a random trance station.

scarecrow420
2004-11-22, 14:39
hi guys, sorry i forgot all about this forum for a while there

i have this resume script almost complete... thanks for the tips on how to do visualisation screen darkie... i wasnt using any gui stuff in the script yet, but ill look at implementing that vis window and then ill release the script to everyone. *ive called it icxbmc (incar xbmc)

what im doing is, remembering the last song to play, and to start playing that automatically on startup... as well as creating a playlist of all other files in that song's directory, so there is something to continue playing once the "last song" finishes. *

ive also got it supporting a "last played file" across teh network, and creating the playlist in the same way as above, but by using the smb.py samba python module to get a directory listing of the file (since the builtin os.listdir() etc commands cant access the shares). *i then pass the samba qualified filename to xbmc to add to the playlist which it happily does. *the only thing is that to make the samba connection you appear to need the ip and hostname of the pc on your network, and you only get one of those from the filename of the playing file in xbmc. *so i need to somehow look up the other one. *or for the moment they are just variables that need to be set at the top of the script if you want that part to work

in all cases, if some error occurs, like a file not existing, then it will try to load a default playlist, specified in the script. it's working quite well in my mates car setup... the vis will be the icing on the cake!

anyway ill get working on showing the visualisation screen and then get back to you all ;)

scarecrow420
2004-11-22, 14:41
pyske - to do that, you would need to be able to determine which ones are "trance" genre. either by reading the information in the /pls file for the shoutcast stream (if it's there), or even easier you could have all the trance stations in a "trance" folder which would make it much easier to code

scarecrow420
2004-11-22, 15:12
well that didnt take long hehehehe... all of 30 minutes. *thanks darkie for showing how to make the visualisations start automatically!!!

ive completed the script to a point where i can release it for everyone else to use. *ive tested this on the latest 15/11 build and it works for me.


ive also tried to comment the code quite a lot, to help any budding scripters out there see what's being done. *i hope some people can take this as a base and modify it further

particularly i kind of just leave it looping at the end... would be nice to have it tidy itself up a bit more, although it doesnt seem to cause any problems, given a car setup is going on and off a fair bit anyway.


anyway without any further ado, you can get icxbmc version 0.9 here: http://members.iinet.net.au/~scarecrow420/icxbmc.zip

make sure you read the readme.txt for installation details and dont forget to set the variables in the top of the script for your setup

PhatheadWRX
2004-11-25, 02:33
can any of you guys help me be a little more efficient.

currently i have autoexec1.py (for smb shared songs) and autoexec2.py (for local songs, for when away from network).
normally auto1 is just autoexec.py, and when i away from network i change them around.

can anyone make a script to attempt to load a smb, then if timeout then load the local playlist?

thanks guys.

solexalex
2004-11-25, 18:00
try this :
import xbmc

pls = xbmc.playlist(0) * * * * * * * * * * * * * * * * * * * ##0 should be music playlist and 2 should be video playlist... not tested
try:
* *pls.load("smb://user:password@/idm/test.m3u")
except:
* *pls.load("q:\\playlist\\test.m3u") * ## always put twice \ for each dirs

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



don't forget to change the path of both of your playlists

xlinkx
2004-11-26, 01:47
scarecrow's script is not working for me =(. *i've tried everything..here's a cut and paste of the autoexec.py. *it's located in /f:/apps/xbmc/scripts/


import xbmc

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

+++++++++++++++++
icxbmc.py *is located in /f:/apps/xbmc/scripts/icxbmc/

settings_file = "q:\\lastplayed.txt"

default_playlist = "f:\\music\\trance\\playlist.m3u"

i tried loading the script manually but it's still not working. *what am i doing wrong??please helppppppppp

scarecrow420
2004-11-26, 10:16
there's a fair oamount of debug output statements in it... you can check what the problem is by looking at the python script output. normally you press the white button from the scripts screen, but as of the latest build the white button doesnt work anymore! im not sure there is a way to get to the script output view until they fix it

or you could try a previous version of xbmc

the only thing im thinking is that in your xboxmediacentre.xml file if you havent already, set the <home> tag at the top to point to xbmc's location eg: <home>f:\apps\xbmc\</home>

this probably wouldnt fix it though... but maybe if there's a problem with it not knowing where q drive is or something. you could try changing the q:\ paths, to the fully qualified f:\ locations maybe

but until you can get to the white button screen, i cant help much!

sorry

xlinkx
2004-11-27, 03:27
there's a fair oamount of debug output statements in it... you can check what the problem is by looking at the python script output. *normally you press the white button from the scripts screen, but as of the latest build the white button doesnt work anymore! *im not sure there is a way to get to the script output view until they fix it

or you could try a previous version of xbmc

the only thing im thinking is that in your xboxmediacentre.xml file if you havent already, set the <home> tag at the top to point to xbmc's location eg: <home>f:\apps\xbmc\</home>

this probably wouldnt fix it though... but maybe if there's a problem with it not knowing where q drive is or something. *you could try changing the q:\ paths, to the fully qualified f:\ locations maybe

but until you can get to the white button screen, i cant help much!

sorry
i've changed the tag to "<home>f:\apps\xbmc\</home>"
and q:\ paths, to the fully qualified f:\ locations

still no lucky with the changes....i guess i'll have to try the previous versions of xbmc

NizZ8
2005-05-05, 08:55
doh!!!.. i totally missed this thread while it was hot.. does anyone have scarecrow420's script that was linked above?... i can't seem to find it anywhere... tia

pygmyrhinovirus
2005-06-01, 06:24
i too, would very very much like a copy of scarecrow's script, it isn't online anymore