Solved Context-menu played item doesn't mark as watched
#1
Check this post for the solution.

Original post below:

I have a playable ListItem, with a context-menu where one of the items is a call to a PlayMedia() with the same URL as that ListItem plus some extra URL parameters.

If I play the ListItem itself, Kodi marks it as watched (the little checkmark icon) as expected.
If I play the context-menu, even though I build another ListItem with the same metadata and setResolvedUrl on it, after watching it, it does not mark that ListItem as watched.

I tested setting the context-menu to use the RunPlugin() or PlayMedia() functions, both give the same result.
Is there a way to let Kodi mark a ListItem as watched when the playback was started from a context-menu on that ListItem?

I'm using Krypton 17.6.
Reply
#2
I see what the problem is.
The problem is that the URL of the ListItem and the URL of its context-menu are different.

The ListItem is added as a directory item with this URL:
"plugin://plugin.video.myvideoplugin/?play=bla.mp4"

The context menu is a call to PlayMedia with this URL:
"plugin://plugin.video.myvideoplugin/?play=bla.mp4&extra_parameter=1"

The only difference between the two is that "&extra_parameter=1" part that the context-menu uses, and that is what is causing Kodi not to mark the item as watched because it thinks the media is different.
If I make the context menu use the exact same URL as the item, it does mark as watched, but then I don't get to send extra parameters in the URL and can't do different logic.

- - - - -
Is there any way I can make the context menu play that same media URL but send extra parameters?
Reply
#3
Can anybody help? 

How can a context menu play something with the same URL but still pass extra parameters? If the plugin:// URL is any different, XBMC will think it's a different media and won't mark-as-watched the listitem where the context-menu was activated on.
Reply
#4
As a workaround I suggest you to provide the argument as window property and ask for this property in you playback function to use it. This doesn't change the url but gives you other options.
Main: Lancool II Mesh  - Ryzen 9 5900x - MSI x570 Unify - Zotac RTX 3080 AMP HOLO - 32GB Trident Z Neo 3600 CL16 -  EVO 960 M.2 250GB / EVO 940 250GB / MX100 512GB /  Crucial P1 2TB / WD Blue 3D Nand 2TB 
Sound: Saxx AS30 DSP - Beyer Dynamic Custom One Pro 
TV: Nvidia Shield 2019 Pro- Adalight 114x LEDs - Sony 65XG9505 - Kodi / Emby - Yamaha RX-V683 - Heco Victa 700/101/251a + Dynavoice Magic FX-4
Server: i3 Skylake - 8GB - OMV4 - 22TB Storage
Reply
#5
@sualfred thanks for the suggestion. What is the program flow going to be, in that case?

The context menu causes a branching: you're playing that item but with something 'extra'. If we set up a window property, how can we know whether we're coming in to play from the context menu, or from just selecting that listitem? 
The window property would have to be set the moment you create the listitem.
Reply
#6
Wooh I think I got it!
First, here's what I was doing and it wasn't working:

- ListItem had path "plugin://plugin.video.myaddon/?play=bla.mp4"
- Context-menu had path "XBMC.PlayMedia(plugin://plugin.video.myaddon/?play=bla.mp4&extra_parameter=1)"

After looking in MyVideosXXX.db (the Kodi video database), those paths are super important, they're used to identify different media. So the context menu and the listitem are always going to be different things, watching one won't watch the other.

After sleeping on it I had this idea, one step of indirection:

- ListItem has path "plugin://plugin.video.myaddon/?play=bla.mp4"
- Context-menu has path "XBMC.RunPlugin(plugin://plugin.video.myaddon/?play=special&extra_parameter=bla.mp4)"

This "special" route then calls a PlayMedia:
python:
ADDON_ID = xbmcaddon.Addon().getAddonInfo('id')

(...)

def specialRoute(params):
    actualPath = 'plugin://%s/?play=%s' % ADDON_ID, params['extra_parameter']
    xbmc.executebuiltin('XBMC.PlayMedia('+actualPath+')')

Since that PlayMedia() inside that function does call the same path as the listitem, the item is marked as watched.
Not sure how clean this extra step of indirection is as the log has a "Failed to find plugin" line after playback ends (I welcome any advice), but I'll take it.
Reply
#7
Sry for the late reply. Even better.

I was told that we should avoid using PlayMedia() because of instability reasons with the busy spinner. Switch to xbmc.Player().play(actualpath) instead.
Main: Lancool II Mesh  - Ryzen 9 5900x - MSI x570 Unify - Zotac RTX 3080 AMP HOLO - 32GB Trident Z Neo 3600 CL16 -  EVO 960 M.2 250GB / EVO 940 250GB / MX100 512GB /  Crucial P1 2TB / WD Blue 3D Nand 2TB 
Sound: Saxx AS30 DSP - Beyer Dynamic Custom One Pro 
TV: Nvidia Shield 2019 Pro- Adalight 114x LEDs - Sony 65XG9505 - Kodi / Emby - Yamaha RX-V683 - Heco Victa 700/101/251a + Dynavoice Magic FX-4
Server: i3 Skylake - 8GB - OMV4 - 22TB Storage
Reply
#8
Hi @sualfred
first of all, I forgot to add how I'm using a persistent Window property for passing data to the next add-on stage so the URL can remain the same, it's these:
python:
def set_property(name, value):
    window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
    return window.setProperty(name, value)

def get_property(name):
    window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
    return window.getProperty(name)
So you can use it like set_property('myProperty', 'https://bla.mp4') -> url = get_property('myProperty') between different add-on screens / folders.
(2019-08-29, 16:04)sualfred Wrote: I was told that we should avoid using PlayMedia() because of instability reasons with the busy spinner. Switch to xbmc.Player().play(actualpath) instead.
That's a good idea, especially because you can send a ListItem with video metadata to the Player.play() function, whereas with the "XBMC.PlayMedia" command you can only send a string path. This helped simplify the code a bit.

I changed the PlayMedia() line to these lines:
python:
    playbackItem = xbmcgui.ListItem(label)
    playbackItem.setInfo("video", { . . . })
    xbmc.Player().play(item=actualPath, listitem=playbackItem) # Send in both the plugin path as well as a ListItem for the metadata.
It works great. Thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
Context-menu played item doesn't mark as watched0