我试图为AutoResume添加KODI的词条。现在addon只保存当前播放歌曲的位置。重新启动后,它会播放这首歌,然后停止。但我想让它开始播放这首歌,然后播放整个播放列表,那是之前播放的。
所以我试着修改代码,但我有个问题。
我试着读这样的播放列表:
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
我做错了什么?
发布于 2017-02-03 12:21:19
如果要获得播放列表的一些信息,XBMC必须使用以下类型:
因此,对于您的示例,您必须从需要此信息的播放列表中选择,因此,如果您想拥有音乐播放列表ID,则必须执行以下操作:
xbmc.PlayList(xbmc.PLAYLIST_MUSIC).getPlayListId()有关更多信息,请查看此链接:VIDEO
发布于 2016-04-11 06:12:43
如果你在课堂上,你试过getPlayListId(自我)吗?
发布于 2019-02-03 23:50:54
我也有过同样的问题。我最终使用了jsonrpc。唯一的警告是你可以播放一个没有播放列表的视频文件,并且你必须用
xbmc.Player().getPlayingFile()我认为getPlayListId是为了获取您已经使用过的播放列表对象,并找到它的id.不一定找到当前播放的播放列表。不过我可能错了。
有三种可能的“播放列表”。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 listhttps://stackoverflow.com/questions/36519487
复制相似问题