get Resume time work on xbmc.player().play()
#1
Hi there,
I'm trying to create own addon with my local server movies different qualities. I have created all local server API endpoints. everything seems to be working fine. but I have an issue with ResumeTime when I use custom player (xbmc.player().play()) instead of `xbmcplugin.setResolvedUrl`

This is why I need to use directory item (isFolder=true) and custom player instead of xbmcplugin.setResolvedUrl. My first request will list all movies and when I click on the movie, it will do another request to local server and get available qualities of that specific movie. I wouldn't know how many qualities available when I requesting the movie list and I need to auto play if there's only one quality available. If there are more qualities available, then list them as a movie item again.

This is the part not working for me. When I user xbmc.player().play(), I cannot get ResumeTime work. anyone have any idea how I can get this ResumeTime work

python:

import sys, xbmc, xbmcgui, xbmcplugin

STREAM_URL = 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'

def run(addon_url):
    # Play video
    if addon_url.endswith('/play'):
        # Only able to check the directory contents at this point (whether play video or display directories)
        listitem = xbmcgui.ListItem(path=STREAM_URL)
        listitem.setInfo('video', {})
        listitem.setProperty('IsPlayable', 'true')
        listitem.setProperty('ResumeTime', str(120))
        listitem.setProperty('TotalTime', str(300))
        # Kodi Player to stop script. hack to play video from directory item
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), succeeded=False, listitem=listitem)
        xbmc.Player().play(STREAM_URL, listitem )

    # Setup menu item
    else:
        xbmcplugin.setContent(int(sys.argv[1]), 'videos')
        listitem = xbmcgui.ListItem(label='video mp4')
        listitem.setInfo('video', {})
        listitem.setProperty('IsPlayable', 'true')
        url = addon_url + '/play?mode=test2'
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, isFolder=True)
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

run(sys.argv[0])
Reply
#2
(2021-04-05, 23:22)Cyberrule Wrote: Hi there,
I'm trying to create own addon with my local server movies different qualities. I have created all local server API endpoints. everything seems to be working fine. but I have an issue with ResumeTime when I use custom player (xbmc.player().play()) instead of `xbmcplugin.setResolvedUrl`

This is why I need to use directory item (isFolder=true) and custom player instead of xbmcplugin.setResolvedUrl. My first request will list all movies and when I click on the movie, it will do another request to local server and get available qualities of that specific movie. I wouldn't know how many qualities available when I requesting the movie list and I need to auto play if there's only one quality available. If there are more qualities available, then list them as a movie item again.

This is the part not working for me. When I user xbmc.player().play(), I cannot get ResumeTime work. anyone have any idea how I can get this ResumeTime work

python:

import sys, xbmc, xbmcgui, xbmcplugin

STREAM_URL = 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'

def run(addon_url):
    # Play video
    if addon_url.endswith('/play'):
        # Only able to check the directory contents at this point (whether play video or display directories)
        listitem = xbmcgui.ListItem(path=STREAM_URL)
        listitem.setInfo('video', {})
        listitem.setProperty('IsPlayable', 'true')
        listitem.setProperty('ResumeTime', str(120))
        listitem.setProperty('TotalTime', str(300))
        # Kodi Player to stop script. hack to play video from directory item
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), succeeded=False, listitem=listitem)
        xbmc.Player().play(STREAM_URL, listitem )

    # Setup menu item
    else:
        xbmcplugin.setContent(int(sys.argv[1]), 'videos')
        listitem = xbmcgui.ListItem(label='video mp4')
        listitem.setInfo('video', {})
        listitem.setProperty('IsPlayable', 'true')
        url = addon_url + '/play?mode=test2'
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, isFolder=True)
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

run(sys.argv[0])
I originally was going to suggest making them floats but that is an internal type.  I looked at my own code and I set them just like you do with strings.  One thing I see different is that I also set duration in the setInfo section but I suspect it might have something to do with setting IsFolder = True. 
 

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#3
(2021-04-06, 01:48)jbinkley60 Wrote:
(2021-04-05, 23:22)Cyberrule Wrote: Hi there,
I'm trying to create own addon with my local server movies different qualities. I have created all local server API endpoints. everything seems to be working fine. but I have an issue with ResumeTime when I use custom player (xbmc.player().play()) instead of `xbmcplugin.setResolvedUrl`

This is why I need to use directory item (isFolder=true) and custom player instead of xbmcplugin.setResolvedUrl. My first request will list all movies and when I click on the movie, it will do another request to local server and get available qualities of that specific movie. I wouldn't know how many qualities available when I requesting the movie list and I need to auto play if there's only one quality available. If there are more qualities available, then list them as a movie item again.

This is the part not working for me. When I user xbmc.player().play(), I cannot get ResumeTime work. anyone have any idea how I can get this ResumeTime work

python:

import sys, xbmc, xbmcgui, xbmcplugin

STREAM_URL = 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'

def run(addon_url):
    # Play video
    if addon_url.endswith('/play'):
        # Only able to check the directory contents at this point (whether play video or display directories)
        listitem = xbmcgui.ListItem(path=STREAM_URL)
        listitem.setInfo('video', {})
        listitem.setProperty('IsPlayable', 'true')
        listitem.setProperty('ResumeTime', str(120))
        listitem.setProperty('TotalTime', str(300))
        # Kodi Player to stop script. hack to play video from directory item
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), succeeded=False, listitem=listitem)
        xbmc.Player().play(STREAM_URL, listitem )

    # Setup menu item
    else:
        xbmcplugin.setContent(int(sys.argv[1]), 'videos')
        listitem = xbmcgui.ListItem(label='video mp4')
        listitem.setInfo('video', {})
        listitem.setProperty('IsPlayable', 'true')
        url = addon_url + '/play?mode=test2'
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, listitem, isFolder=True)
        xbmcplugin.endOfDirectory(int(sys.argv[1]))

run(sys.argv[0])
I originally was going to suggest making them floats but that is an internal type.  I looked at my own code and I set them just like you do with strings.  One thing I see different is that I also set duration in the setInfo section but I suspect it might have something to do with setting IsFolder = True. 
 

Jeff


Hi Jeff, thank you for your reply.
it didn't work even when I change that to float. setProperty is only accepting string or unicode. I tried like this str('120.0'). still didn't work. I went through this same documentation before. but right now with your link I found that following code is doing the trick what I need. thanks
python:
listitem.setProperty('StartOffset', str(120))

also your documentation url is scrambled. I just corrected it here for future use. https://codedocs.xyz/AlwinEsch/kodi/grou...53667e7d81
Reply
#4
StartOffset property on playitems isn't working, use xbmc.Player().SeekTime() instead. Not the best option and it's not exacly bulletproof, but I couldn't find any other solution.
Reply

Logout Mark Read Team Forum Stats Members Help
get Resume time work on xbmc.player().play()0