0

I am trying to mod AutoResume addon for KODI. Now the addon only saves current playing song an position. And after reboot it will play that song and then stop. But I want it to begin playing the song and then play whole playlist, that was playing before.

So I tried to change the code, but I have a problem.

I am trying to read playlist id like this:

mediaFile = xbmc.Player().getPlayingFile()
position = xbmc.Player().getTime()

# The line in question:
playList = xbmc.PlayList().getPlayListId()

# Write info to file
f = open('/home/pi/autoresume.txt', 'w')
f.write(mediaFile)
f.write('\n')
f.write(repr(position))
f.write('\n')
f.write(repr(playList))
f.close()

But python gives me this:

-->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.TypeError'>
Error Contents: function takes exactly 1 argument (0 given)
Traceback (most recent call last):
File "/home/pi/.kodi/addons/service.autoResume-master/default.py", line 79, in <module>
recordPosition()
File "/home/pi/.kodi/addons/service.autoResume-master/default.py", line 59, in recordPosition
playList = xbmc.PlayList().getPlayListId()
TypeError: function takes exactly 1 argument (0 given)
-->End of Python script error report<--

If I understand this correctly there is missing argument in getPlaylistId(), but this method does not need parameter: http://mirrors.xbmc.org/docs/python-docs/stable/xbmc.html#PlayList-getPlayListId

What am I doing wrong?

Anil_M
  • 10,893
  • 6
  • 47
  • 74
Kamion
  • 3
  • 3

3 Answers3

0

Have you tried getPlayListId(self), if your in a class?

Razze
  • 4,124
  • 3
  • 16
  • 23
0

XBMC has following types that have to be used if you would have some information of a Playlist:

  • xbmc.PLAYLIST_MUSIC
  • xbmc.PLAYLIST_VIDEO

So for your example you have to choose from which playlist you want this information so if you want to have the Music Playlist ID then you have to do the following:

xbmc.PlayList(xbmc.PLAYLIST_MUSIC).getPlayListId()

Check this link for more information: http://www.programcreek.com/python/example/77742/xbmc.PLAYLIST_VIDEO

Spezi94
  • 91
  • 10
0

I had the same issue. I ended up using jsonrpc instead. The only caveat is that you can play a video file without a playlist and you have to check it with

xbmc.Player().getPlayingFile()

I think the getPlayListId is meant to take a playlist object that you already used and find its id... not necessarily find the current playing playlist. I could be wrong though.

There are 3 possible "playlists". 0 is audio, 1 is video, and not sure of 2. I poll all 3 and write into a database to preserve whatever I send to a list. These are what I use:

plid[0] = json.loads(xbmc.executeJSONRPC(
    '{"jsonrpc":"2.0", "method": "Playlist.GetItems", "params":{"properties":["file"], "playlistid":0'
    + '},"id":0}'))
plid[1] = json.loads(xbmc.executeJSONRPC(
    '{"jsonrpc":"2.0", "method": "Playlist.GetItems", "params":{"properties":["file"], "playlistid":1'
    + '},"id":1}'))
plid[2] = json.loads(xbmc.executeJSONRPC(
    '{"jsonrpc":"2.0", "method": "Playlist.GetItems", "params":{"properties":["file"], "playlistid":2'
    + '},"id":2}'))

Edit: I just found an easier way to see if you need getPlayingFile(). If you find the active player with jsonrpc and then check the playlist position of the playing media a position of -1 means it's not in a playlist :

data = json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Player.GetActivePlayers", "id":0}'))

if xbmc.PlayList(data["result"][0]["playerid"]).getposition() < 0:
    # playing file outside of play list
wrinkols
  • 1
  • 1