View Full Version : xbmc.Player().play() does not play my file
Hi everyone again,
i'm trying to play a file via the funtion xbmc.player().play(file) ! the file is stored on a smb network share (smb://test:password@192.168.0.10/Music/03 - Song.ogg). when i call the function with the given address the player does not do anything!? is the address incorrect or the function deprecated?
Is there perhaps another function which can stack up items in the playlist?
Sorry for my bad english und best regards
koprom
I've found out that the problem is the address of the file. If i put a file test.ogg to drive E on the xbox i can play this file without any problems. Is this function limited to files from local drives? or is smb mapped to specific drive letter?
Greetings
koprom
I can't get the xbox to play the file. Tried every combinatino of slashes or backslashes in the location of the file. It doesn't work. I thought it would be enough to concatenate the 'strPath' Value from the database-table path and the 'strFileName' Value from the table song. But this doesn't work? Are Python scripts limited to local files?
Greetings
koprom
gzusrawx
2007-05-21, 15:25
try using this instead
XBMC.PlayMedia(medialocation) for example
XBMC.PlayMedia(F/stuff/test.avi)
Now python gives the error message: module 'xbmc' has no attribute 'PlayMedia'
Greetings koprom
LiquidIce629
2007-05-21, 16:49
Is this in Python?
You can give this a try:
file = "F:\music\test.mp3"
print xbmc.executebuiltin('xbmc.playmedia(' + file + ')')
print xbmc.executehttpapi("AddToPlaylist("+file+");0")
command=PlayFile¶meter=F:\music\test.mp3
When trying this:
file = "smb://test:1234@192.168.0.1/Music/01 - Song.ogg"
print xbmc.executebuiltin('xbmc.playmedia(' + file + ')')
print xbmc.executehttpapi("AddToPlaylist("+file+");0")
the output was:
<li> Error
None
<li> Error
Greetings
koprom
Nuka1195
2007-05-24, 01:57
import xbmc, xbmcgui
def get_browse_dialog( default="", heading="", type=1, shares="files", mask="", use_thumbs=False, treat_as_folder=False ):
""" shows a browse dialog and returns a value
- 0 : ShowAndGetDirectory
- 1 : ShowAndGetFile
- 2 : ShowAndGetImage
- 3 : ShowAndGetWriteableDirectory
"""
dialog = xbmcgui.Dialog()
value = dialog.browse( type, heading, shares, mask, use_thumbs, treat_as_folder, default )
return value
file = get_browse_dialog( heading="Song to play", mask=".mp3|.ogg" )
print file
xbmc.Player().play( file )
The above works fine for me, though I don't use passwords.
Use that and then see if the file you want plays, if so view the debug output and see what the line should look like.
Also make sure you have a share to that folder or atleast a smb:// share in filemanager.
Okay i tried your script and it works perfectly even with passworded shares. I combined it with my script to find differences in the smb address.
Here is my script with some imports left out:
band = 'Coldplay'
cur.execute("SELECT idArtist FROM artist WHERE strArtist = '" + band + "'")
row = cur.fetchone()
if(not row == None):
band_id = str(row[0])
cur.execute("SELECT idPath, strFileName FROM song WHERE idArtist = '" + band_id + "' AND strTitle = '" + songname + "'")
row = cur.fetchone()
if(not row == None):
idPath = str(row[0])
filename = row[1]
if(not idPath == ''):
cur.execute("SELECT strPath FROM path WHERE idPath = '" + idPath + "'")
row = cur.fetchone()
path = str(row[0])
complete = path + filename
print complete
#==================
def get_browse_dialog( default="", heading="", type=1, shares="files", mask="", use_thumbs=False, treat_as_folder=False ):
""" shows a browse dialog and returns a value
- 0 : ShowAndGetDirectory
- 1 : ShowAndGetFile
- 2 : ShowAndGetImage
- 3 : ShowAndGetWriteableDirectory
"""
dialog = xbmcgui.Dialog()
value = dialog.browse( type, heading, shares, mask, use_thumbs, treat_as_folder, default )
return value
file = get_browse_dialog( heading="Song to play", mask=".mp3|.ogg" )
print file
#=================
test = ("smb://test:1234@192.168.1.1/Musik/Coldplay/2000 - Parachutes/05 - Yellow.ogg")
print test
xbmc.Player().play( complete ) # Does not work
xbmc.Player().play( file ) # Works
xbmc.Player().play( test ) # Works
And this is the Output as seen on my TV or in the test environment on the pc:
smb://test:1234@192.168.1.1/Musik/Coldplay/2000 - Parachutes/05 - Yellow.ogg
smb://test:1234@192.168.1.1/Musik/Coldplay/2000 - Parachutes/05 - Yellow.ogg
smb://test:1234@192.168.1.1/Musik/Coldplay/2000 - Parachutes/05 - Yellow.ogg
There is no difference in the output of the strings, so perhaps they have a different type (i'm not a python expert)? Or do i have to escape the string?
Thanks for your help nuka1195
Greetings
koprom
Okay i've found the solution. With the python function 'type' i found out that sqlite does not return objects of the type 'str' (as play needs them) but unicode objects (which play regrets)!
The solution is every unicode object has a function encode('charset') where charset could be 'utf-8' which i use at the moment. This function return a 'str' object with the (hopefully) the same contents as the unicode object.
Greetings
koprom