Kodi Community Forum
Start Playback at Bookmark? - 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: Start Playback at Bookmark? (/showthread.php?tid=241412)



Start Playback at Bookmark? - dingerjunkie - 2015-10-06

Hello All,

I've spent about two hours searching and haven't found what I'm looking for...help would be appreciated...

I'm looking to set up a method by which I can play four or five movie sections in sequence from multiple files. Each of these sections are mid-movie. I am using this as a way to demo my system with what I consider to be the most impressive scenes so people can see what the system is capable of rendering.

The big question...how do I start playing a file from a specific point in time? Let's say, as an example, I wanted a clip from Iron Man. I know how to kick the file off in a Python script...

xbmc.executebuiltin("PlayMedia(\\var\\media\\KINGSTON\\IronMan.mkv)")

What do I add if I want it to automatically, consistently start playing Iron Man at the 15:32 mark, without prompting, for some reason?

Thanks for any insight you can provide.


RE: Start Playback at Bookmark? - Eldorado - 2015-10-06

Lookup the seekTime() method on the xbmc.Player class

eg

Code:
class MyPlayer (xbmc.Player):

    def onPlayBackStarted(self):
        try:
            self.seekTime(float(932))
        except:
            pass

Note - seekTime is in seconds, must pass as a float


RE: Start Playback at Bookmark? - ironic_monkey - 2015-10-06

http://paste.ubuntu.com/12698323/ examplifies a better way.

EDIT: reason i say it's better is that the player is told up front, and won't start decoding from the start of the file, then immediately being told to seek.


RE: Start Playback at Bookmark? - Eldorado - 2015-10-06

I was never able to get it to work that way, not sure what I was missing

Though I was using the ResumeTime property instead of StartPercent

Code:
listitem.setProperty('ResumeTime', '932')


Edit - well StartPercent works.. still can't figure out why ResumeTime doesn't for me

Edit edit - StartOffset works well, giving it the # of seconds to start at

Edit edit edit - Where can one find a list of valid properties? I only find these by chance, never spotted these documented anywhere


RE: Start Playback at Bookmark? - ironic_monkey - 2015-10-07

dunno, i always check the code..


RE: Start Playback at Bookmark? - Wimpie - 2015-10-07

(2015-10-06, 19:11)Eldorado Wrote: Lookup the seekTime() method on the xbmc.Player class

Note - seekTime is in seconds, must pass as a float

Are you sure SeekTime needs a float?
I use in in my addon and it works while I use an int.


RE: Start Playback at Bookmark? - dingerjunkie - 2015-10-07

What I have working so far is the following...

addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')
xbmc.Player().play("\\storage\\movies\\Animal House (1978)\\Animal House.mkv")
xbmc.Player().seekTime(932)
time.sleep(60)

However, I'm running into two follow-on issues.

First, I run into problems with the next line failing...

xbmc.Player().stop

For some reason, the "stop" command is being ignored. No error message, just no positive response to the stop. I'm thinking that I'll avoid this by running a playlist where I play to the end of the last file in the list, though it would be nice if "stop" actually worked.

Second, the entire time that the script is "sleeping," I get the "working" prompt in the top-center of the screen/skin while viewing content. Does anyone know a way to temporarily make Kodi run Python scripts in "silent mode?"

Thanks again for all of the input.


RE: Start Playback at Bookmark? - Eldorado - 2015-10-07

(2015-10-07, 12:39)Wimpie Wrote:
(2015-10-06, 19:11)Eldorado Wrote: Lookup the seekTime() method on the xbmc.Player class

Note - seekTime is in seconds, must pass as a float

Are you sure SeekTime needs a float?
I use in in my addon and it works while I use an int.

Nope, not sure at all Smile

Sounds like either way will work depending on how much precision you want


RE: Start Playback at Bookmark? - dingerjunkie - 2015-10-07

I'm a fool...missed minor syntax add...the () after "stop"...now I'll be good as soon as I can get rid of the "working" prompt and have the script run "silently"