Hi,
I'm trying to figure out how to make the playcount / "Mark as watched" feature working properly in a plugin. I've stripped down the source code to a bare minimum, which can be found here:
https://github.com/plu/plugin.video.play...default.py
What I do:
* Open context menu on one of the two items
* Mark as watched
What I expect to happen:
* It marks the video as watched and shows the checkmark
What happens instead:
* It does not mark the video as watched, neither it does show the checkmark
What am I missing? Any hints are appreciated!
I'm running Kodi 16.1 Git:2016-04-24-c327c53 on Mac OS 10.11.5.
Thanks,
Johannes
Using direct links to network streams is a bad idea for several reasons:
First, for each link Kodi issues a HEAD request, trying to get media item metadata. This may slow down rendering media lists with large number of items.
Second, yes, "watched"/"in progress" marks do not work for direct network links for some reason.
A best practice for Kodi media plugins is to play media items via a plugin callback that calls xbmcplugin.setResolvedUrl() function at the end.
Thank you for the hint! Pointing back now to my addon via plugin://plugin.video.wwdc/?action=Play&sessionID=228 and using setResolvedUrl() now.
Good thing: Resume is working now, also the video is properly marked as watched. But what is missing is the "Mark as watched/unwatched" context menu item. Any hints what I might be missing?
Code:
def actionPlay(self, params):
sessionID = params.pop('sessionID')
session = self.sessions.find(sessionID)
item = xbmcgui.ListItem(session.title, path=session.url, iconImage=session.fanart, thumbnailImage=session.fanart)
xbmcplugin.setResolvedUrl(handle=self.handle, succeeded=True, listitem=item)
def actionYear(self, params):
year = params.pop('year', '2016')
sessions = []
for session in sorted(self.sessions.list(year), key=lambda x: x.title, reverse=False):
url = self.urlFor({'action': 'Play', 'sessionID': session.sessionID})
item = xbmcgui.ListItem(session.title, path=url, iconImage=session.fanart, thumbnailImage=session.fanart)
item.setInfo('video', {
'title': session.title,
'plot': session.description,
'year': session.year,
'duration': session.duration,
})
item.setProperty('IsPlayable', 'true')
sessions.append((url, item, False))
xbmcplugin.addDirectoryItems(self.handle, sessions, len(sessions))
xbmcplugin.endOfDirectory(self.handle)
You have to add your own context menu item for marking as watched/unwatched. If I'm not mistaken, it should be something like this:
Code:
item.addContextMenuItems([('Mark as wached/unwatched', 'Action(ToggleWatched)')])