Newb to scripting, few questions
#1
I'm trying to put together a script, that will load and play a video playlist. I'm using Thor918's MyPlayer class to overlay xbmc.Player so I can hook into the Stop/Start/Ended events.

My problem is, how to keep my script from exiting...

My first attempt was to put a while loop in once everything was setup, with a sleep in the while loop. This appears to work when testing on the PC using XBMC_PC, but on the actual xbox, it doesn't work as well.

I end up not getting my function calls from the player events. I'm assuming, this is because I'm in a sleep state when they're triggered.

My next attempt was to use a blank window, so I could use a doModal() call to keep my script running. That seems to leave me with a rapidly flashing video where my blank window keeps swapping focus with the playing video. It also crashes XBMC_PC Sad

I feel like I'm overlooking a rather simple and obvious method of doing this, I just can't come up with it, and I've been searching around, but haven't found an example.
Reply
#2
Can anyone try this and tell me if it works, or tell me what I'm missing?

Code:
import xbmc

smblist = "smb://user:password@server/clips/Clips.m3u"

player = xbmc.Player(xbmc.PLAYER_CORE_MPLAYER)

playlist = xbmc.PlayList(1)
playlist.load(smblist)
print "Starting playlist..."
player.play(playlist)
while player.isPlaying():
    print " (" + str(player.getTime()) + ") " + player.getPlayingFile()
    xbmc.sleep(2000)

It seems like the player's not updating or properly returning the currently playing file. This is using the 2-24 version of T3CH.

I displays the first file, but if I skip forward to other files, it still shows the last file. Occasionally, it will update to the playing file, but most of the time, it simply reports the first file. Even if I let it play through the first file, and move on to the next by itself, it doesn't update.

I've also noticed the same behavior if I ask the playlist object which item is playing, it stays at 0 most of the time.

Bug, or something stupid I'm doing/overlooking? I suspect the later since I'm new to Python and scripting XBMC.

I've been reading and searching everything relevant on this forum and the wiki, and as far as I can tell, what I'm doing should work.

Oh, and it works perfectly on XBMC_PC, just not on either of my xbox's Sad
Reply
#3
Try this:

Code:
import xbmc

smblist = "smb://login:pass@server/mylist.m3u"

player = xbmc.Player(xbmc.PLAYER_CORE_MPLAYER)

playlist = xbmc.PlayList(1)
playlist.load(smblist)
print "Starting playlist..."
player.play(playlist)
if player.isPlaying():
    print " (" + str(player.getTime()) + ") " + player.getPlayingFile()
    # xbmc.sleep(2000)

Since you had the 'while' you had an endless loop. The 'if' statement is more proper. I tried this script on a m3u file of mp3's and it worked fine updating the names...
Reply

Logout Mark Read Team Forum Stats Members Help
Newb to scripting, few questions0