Correct use of xbmc.Player in Python?

playList = xbmc.PlayList(0)
currentPos = playList.getposition()
numAdded = 0

xbmc.sleep(100) #Kodi playlists usually require a moment to execute the clear call before adding (Known issue).
for l in LinkURL:
    if not l == "":
        numAdded += 1

myPlayer = xbmc.Player() #make Player() a single call.
tm = myPlayer.getTime()
fn1 = myPlayer.getPlayingFile()
xbmc.log("current file: %s" % fn1, xbmc.LOGWARNING)
xbmc.log("current time: %g" % tm, xbmc.LOGWARNING)
myPlayer.stop() = playList, startpos = 0)
fn2 = myPlayer.getPlayingFile()
# fn2 = fn1
xbmc.log("    new file: %s" % fn2, xbmc.LOGWARNING)
if fn1 == fn2:
    xbmc.log("before seekTime", xbmc.LOGWARNING)
    xbmc.log("Player.getTime is now: %g" % myPlayer.getTime(), xbmc.LOGWARNING)
    xbmc.log("seek to %g" % tm, xbmc.LOGWARNING)
    xbmc.log("Player.getTime is now: %g" % myPlayer.getTime(), xbmc.LOGWARNING)
    xbmc.log("after seekTime", xbmc.LOGWARNING)
    xbmc.log("diferrent file - not seeking", xbmc.LOGWARNING)

xbmcgui.Dialog().notification(__scriptname__, "%d titles were added to the playlist" % playList.size())

Made some minor corrections to the snippet above. frankly, this code looks more like a pseudo-code it's not really functional. You mentioned it's "part" of a greater project... perhaps you should show all work?

As is; you can only check the first position in the playlist index (0), then the script terminates. fn2 will always be Position 0...

Can you elaborate on what you are trying to achieve?
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Twitter | Help?

Messages In This Thread
RE: Correct use of xbmc.Player in Python? - by Lunatixz - 2021-03-07, 21:46

Logout Mark Read Team Forum Stats Members Help
Correct use of xbmc.Player in Python?0
This forum uses Lukasz Tkacz MyBB addons.