Win Add-on doesn't want to show video
#1
I'm developing an addon that is able to play videos from the internet, but it doesn't want to play them.
In my code I have the following:
python:
def PlayVideo(url, handle=int(sys.argv[1])):
    play_item = xbmcgui.ListItem(path="https://ia800908.us.archive.org/30/items/TheStranger_0/The_Stranger_512kb.mp4") # This will later be replaced with the url variable once I get this to work.
    xbmcplugin.setResolvedUrl(handle, True, listitem=play_item)
I am also sure this function is getting called, so what am I doing wrong? Looking at other video add-ons doesn't help much either...
Reply
#2
context matters -

how is your addon being called, is it running as a video plugin where users then click on a listitem which calls PlayVideo?

try -

xbmcplugin.setResolvedUrl(handle, succeeded=True, listitem=play_item)

otherwise -

what is the Debug Log saying when it fails to play?
Reply
#3
If it is a plugin with listitems you click on to play a video, ensure to call setProperty("IsPlayable", "true") on these listitems (you click on).
Reply
#4
(2023-08-01, 22:05)jepsizofye Wrote: how is your addon being called, is it running as a video plugin where users then click on a listitem which calls PlayVideo?
Yes
(2023-08-01, 22:05)jepsizofye Wrote: xbmcplugin.setResolvedUrl(handle, succeeded=True, listitem=play_item)
(2023-08-02, 00:06)kereltje Wrote: ensure to call setProperty("IsPlayable", "true") on these listitems (you click on)
Doesn't work either
(2023-08-01, 22:05)jepsizofye Wrote: what is the Debug Log saying when it fails to play?
wafopupiyo.kodi (paste)
Reply
#5
I must say, you're not making it very easy for us to help you.
The code posted is OK, so something else is going wrong, but we can only guess. Please post the surrounding code like @jepsizofye suggested.

The log has no debug info. Enable debug logging in settings > system > logging.

You mentioned you're sure the code gets called, but not what you did to check that. In all the things you think you've done right, there is obviously something wrong. This check could well be it.

Anyway, from the log:
2023-08-02 08:20:38.950 T:11500 warning <general>: [COLOR yellow]AcesVideos[/COLOR] > ('IsPlayable', 'true')
Makes me wonder whether you've set the property the right way. https://xbmc.github.io/docs.kodi.tv/mast...310ce86a25
Reply
#6
(2023-08-02, 14:50)kereltje Wrote: Anyway, from the log:
2023-08-02 08:20:38.950 T:11500 warning <general>: [COLOR yellow]AcesVideos[/COLOR] > ('IsPlayable', 'true')
Makes me wonder whether you've set the property the right way.
It's just my code logging stuff, it logs the variable "item" (which is 
python:
('IsPlayable', 'true')
), and in the next line it runs 
python:
list_item.setProperty(item[0], item[1])
, so I should still be setting the property the right way.
(2023-08-02, 14:50)kereltje Wrote: You mentioned you're sure the code gets called, but not what you did to check that. In all the things you think you've done right, there is obviously something wrong. This check could well be it.
Logging. Whenever it reaches the PlayVideo function, I made it log the url and handle variables. I didn't put it in my original post to try to avoid confusion.
(2023-08-02, 14:50)kereltje Wrote: The code posted is OK, so something else is going wrong, but we can only guess. Please post the surrounding code like @jepsizofye suggested.
plugin.video.acesvideo/lib/utils.py: https://pastebin.com/7pqyeP3g
plugin.video.acesvideo/default.py: https://pastebin.com/N8WqcX5V
(2023-08-02, 14:50)kereltje Wrote: The log has no debug info. Enable debug logging in settings > system > logging.
This one should have debug logging enabled: qixuqulibi.kodi (paste)
Reply
#7
comparing your code to code ive used i see 2 differences

the first, i add each item 1 at a time with xbmcplugin.addDirectoryItem and you add a list of items with xbmcplugin.addDirectoryItems, i dont think this means anything but just 2 sides of a coin but i mention it in case mine behaves differently because of this

the second i dont see where you are setting the media type so try this -


python:
def addItem(self, label, image=ADDON_ICON, data={}, color="yellow", infoType=None, infoLabels=None, **properties):
    list_item = xbmcgui.ListItem(f"[COLOR {color}]{label}[/COLOR]", label2=label)
    list_item.setArt({ "thumb": image })
    list_item.setIsFolder(False)
    
    if infoType and infoLabels:
        list_item.setInfo(infoType, infoLabels)
    
    for item in properties.items():
        XbmcDebug(item)
        list_item.setProperty(item[0], item[1])
        
    vinfo = list_item.getVideoInfoTag()
    vinfo.setTitle(label)
    vinfo.setMediaType("video")

    self.listItems.append((BuildURL(data), list_item, False))



from the log it does not look like kodi is trying to play anything so setting media type to video should yield a different result
Reply
#8
in utils.py line 48:
python:

        self.listItems.append((BuildURL(data), list_item, True))
Argument True makes the listitem a folder 

from Kodi docs:

Function: xbmcplugin.addDirectoryItems(handle, items[, totalItems])

Parameters:
    items    List - list of (url, listitem[, isFolder]) as a tuple to add.

Change to
Python:
self.listItems.append((BuildURL(data), list_item, False))
and it will play
Reply
#9
that would make a big difference as well @kereltje nice catch
Reply
#10
Thanks, these changes seems to fix the video not starting. But now it freezes Kodi when I try to press stop.
Reply
#11
(2023-08-02, 17:00)AceKiron Wrote: But now it freezes Kodi when I try to press stop.
Nvm, that happened to just be a one time thing apparently, thanks for the help.
Reply

Logout Mark Read Team Forum Stats Members Help
Add-on doesn't want to show video0