Kodi Community Forum
Solved Start from beginning doesn't work - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Solved Start from beginning doesn't work (/showthread.php?tid=337137)



Start from beginning doesn't work - quarck - 2018-11-03

I've been developing a video plugin with syncing resume points across devices. I get a resume point from the server and then I set it with:
python:
xbmcgui.ListItem.setProperty("resumetime", "some_seconds")
xbmcgui.ListItem.setProperty("totaltime", "some_seconds")
When I click on a list item the context menu appears with two choices: "Resume from ..." and "Start from beginning". Resume works fine, but start from beginning doesn't. It always starts from the resume point. Is it a bug in Kodi or I do something wrong? How to fix that issue? The sources of the addon is here https://github.com/quarckster/kodi.kino.pub.


RE: Start from beginning doesn't work - Wimpie - 2018-11-03

Maybe connected...
https://forum.kodi.tv/showthread.php?tid=336638


RE: Start from beginning doesn't work - quarck - 2018-11-04

Neither "StartPercent" nor "StartOffset" don't set the resume time for me.


RE: Start from beginning doesn't work - ronie - 2018-11-05

i've tested it with a very basic plugin and 'start from beginning' works fine for me.
python:
import sys
import xbmcgui
import xbmcplugin

addon_handle = int(sys.argv[1])
url = '/home/ronie/videos/mymovie.mp4'

li = xbmcgui.ListItem('My Movie')
li.setProperty('totaltime', '800')
li.setProperty('resumetime', '200')

xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
xbmcplugin.endOfDirectory(addon_handle)



RE: Start from beginning doesn't work - quarck - 2018-11-05

I fixed the issue in my plugin. I found out that you don't need to set resume time and do any setInfo call for a list item in a function where you call xbmcplugin.setResolvedUrl. Basically you should do something like this:

python:
def list_items():
    li = xbmcgui.ListItem('My Movie')
    li.setProperty('totaltime', '800')
    li.setProperty('resumetime', '200')
    #  url leads to "play" function
    xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
    xbmcplugin.endOfDirectory(addon_handle)

def play():
    li = xbmcgui.ListItem('My Movie', path=url)
    xbmcplugin.setResolvedUrl(request.handle, True, li)
 
I would say it's unobvious behavior. A list item in play function doesn't contain any information about resume time, but neveretheless it will be automagically played from the correct point. Thanks everyone. The thread can be closed as resolved.