我正在尝试为AutoResume
修改KODI
插件。现在addon
只保存当前播放的歌曲位置。重新启动后,它将播放该歌曲然后停止。
但是我希望它能够开始播放这首歌,然后播放整个播放列表,那就是之前播放的。
所以我尝试更改代码,但是我遇到了问题。
我正在尝试阅读这样的播放列表ID:
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()
但是python给了我这个:
-->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<--
如果我理解正确,getPlaylistId()中缺少参数,但此方法不需要参数: http://mirrors.xbmc.org/docs/python-docs/stable/xbmc.html#PlayList-getPlayListId
我做错了什么?
答案 0 :(得分:0)
如果你有一些播放列表的信息,XBMC有以下必须使用的类型:
因此,对于您的示例,您必须从哪个播放列表中选择您想要此信息,因此,如果您想拥有音乐播放列表ID,则必须执行以下操作:
xbmc.PlayList(xbmc.PLAYLIST_MUSIC).getPlayListId()
检查此链接以获取更多信息: http://www.programcreek.com/python/example/77742/xbmc.PLAYLIST_VIDEO
答案 1 :(得分:0)
我有同样的问题。我最终改为使用jsonrpc。唯一的警告是您可以在没有播放列表的情况下播放视频文件,并且必须使用
进行检查xbmc.Player().getPlayingFile()
我认为getPlayListId旨在获取您已经使用的播放列表对象并找到其ID ...不一定找到当前的播放列表。我可能是错的。
有3种可能的“播放列表”。 0是音频,1是视频,不确定2。我轮询所有3,并将其写入数据库以保留发送到列表的内容。这些是我使用的:
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}'))
编辑: 我只是找到了一种更简单的方法来查看是否需要getPlayingFile()。如果您找到带有jsonrpc的活动播放器,然后检查播放媒体的播放列表位置,则位置-1表示该播放器不在播放列表中:
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