Correct use of xbmc.Player in Python?
(2021-03-07, 21:46)Lunatixz Wrote:

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?
I missed it at first... sleep(100) fixed the problem with the player not starting!

In fn2 I am checking the new head of the playlist. If this track and the seed track are the same, I attempt to skip to the last known position, this is still problematic!

Messages In This Thread
RE: Correct use of xbmc.Player in Python? - by splatterpop - 2021-03-08, 22:20

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