Kodi Community Forum
Python mediaplay() not working - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Archive (https://forum.kodi.tv/forumdisplay.php?fid=92)
+--- Forum: First-generation XBOX support (https://forum.kodi.tv/forumdisplay.php?fid=158)
+--- Thread: Python mediaplay() not working (/showthread.php?tid=810)



- NEI - 2004-01-04

just wanted to autostart a shoutcaststream, but this won't work at the moment. don't know if it's a bug or not supported.


- darkie - 2004-01-04

how do you autostart it?
xbmc.mediaplay("file.pls")
or
xbmc.mediaplay("[url]http://shoutcast"[/url]) ?

the last should work, the first shouldn't.


- NEI - 2004-01-04

nice, will try it later.

*****edited:
forget everything. it's almost working. the problem is something with the xfs i have to check later...
*****
btw, as you are the python guru... :-)
could you give me an example how to make directories and remove them. can i access the f: drive through python?
i wrote a shoutcast-pls-updater this afternoon, but can't get it to work on the xbox. works nice on winxp, but thats not what i want! :-)
i'm new to python, here the relevant functions:

...
shoutcast_dir = 'f:/music/radio/'
...
#got this one from somewhere here in the forum, but doesn't work on the box:
def clean_dir(dirname):
for root, dirs, files in os.walk(dirname):
for name in files:
os.remove(join(root, name))

#creates missing directories for the given path
def make_path(path):
dpath = normpath(dirname(path))
if not exists(dpath): makedirs(dpath)
return normpath(abspath(path))


# saves the content under the given path. (i.e. dir=f:/music/shoutcast/ filename=blabla.pls)
def save_file(dir, filename, content):
make_path(dir)
file = open(dir + filename, 'w')
file.writelines(content)
file.close

thanx a lot
n8


- darkie - 2004-01-05

just a quick look
'/' is not supported in python for xbmc
use '\\' instead

shoutcast_dir = 'f:\\music\\radio'


- Hullebulle - 2004-01-05

since this turns into python scripting i move it to the "development" forum. Smile