Resume a video in a playlist.
#1
Hi there!

I've been working on an addon for a couple of months now that creates and manages dynamic playlists. You click a button in the addon, and it adds the episodes to the playlist.

What I've been trying to figure how is how to resume an episode on that playlist.

For example:
You've been watching the 5th episode in the playlist
You close Kodi and come back, and I've stored which episode you are on.
You click a button and it recreates that playlist and starts the 5th episode in that playlist, and it resumes where you were in that episode.

What I have working:
I can recreate the playlist, then start the 5th episode. But it won't resume. If I go to the playlist and manually start the episode it resumes fine, but not from my addon.

Here's the code I am currently using:

Code:
xbmc.executebuiltin(
                    'Playlist.PlayOffset(%s,%d)' % ('Video', i)
                 )

Here are the other things I've tried:

Code:
# Get the playlist.
                play = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)

                xbmc.executebuiltin(
                    'Playlist.PlayMedia(%s,resume, playoffset=%d)' % (play.getPlayListId(), i))

                xbmc.Player().play(play[i].getfilename())

                xbmc.Player().play(play, startpos=-1)

It seems like Playlist.PlayMedia has the ability to resume, but I can't figure out how to send it a playlist that isn't on the disk. I just want the currently loaded playlist.

Does anyone have any ideas? Thanks a ton!
Reply
#2
Why are you mixing kodi builtin's and kodi player methods?

Judging by your pseudocode you are failry new to Kodi development? I'd suggest posting your full code this way proper guidance can be given.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
I'm not mixing Kodi builtin's and Kodi player methods, those were just the other things that I have tried (each line a different attempt).

I'm just going to keep track of the playback myself and handle the resume in my addon for now unless I can get something working. Looking at the source for the Kodi builtins it looks like PlayMedia sets m_lStartOffset on the playlist item if resume is true, which allows the item to resume:

https://github.com/xbmc/xbmc/blob/754601...s.cpp#L411

But PlayOffset doesn't do anything like this. Currently I'm experimenting with setting StartOffset on the listitem and starting it with PlayOffset:

listitem.setProperty('StartOffset', '-1')

Kodi will turn this into m_lStartOffset, which looks to be correct:

https://github.com/xbmc/xbmc/blob/1571c7...m.cpp#L208

I'll report back.
Reply
#4
(2017-07-27, 04:23)octalmage Wrote: I'm not mixing Kodi builtin's and Kodi player methods, those were just the other things that I have tried (each line a different attempt).

I'm just going to keep track of the playback myself and handle the resume in my addon for now unless I can get something working. Looking at the source for the Kodi builtins it looks like PlayMedia sets m_lStartOffset on the playlist item if resume is true, which allows the item to resume:

https://github.com/xbmc/xbmc/blob/754601...s.cpp#L411

But PlayOffset doesn't do anything like this. Currently I'm experimenting with setting StartOffset on the listitem and starting it with PlayOffset:

listitem.setProperty('StartOffset', '-1')

Kodi will turn this into m_lStartOffset, which looks to be correct:

https://github.com/xbmc/xbmc/blob/1571c7...m.cpp#L208

I'll report back.
Looking at your code would have helped guide your development. xbmc.Player can handle everything you need in regards to playlists, loading, seeking, resuming...

https://codedocs.xyz/xbmc/xbmc/group__py..._list.html
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply

Logout Mark Read Team Forum Stats Members Help
Resume a video in a playlist.0