precache while playing other item in playlist
#1
Question 
Hello everyone.

I'm coding a simple addon, and want to do the following:
- create empty playlist
- add to playlist: local media "somevideo.mp4"
- add to playlist: internet video "externalvideo.mp4"
- start playing
- while playing the local media, start precaching the next item in the playlist
- when local somevideo.mp4 ended, the "externalvideo.mp4" should be partially or totally cached so the system won't lag and will play it right away.

There is some internal workings of Kodi that i don't fully understand about this. I think that kodi already caches partially the playlist items, but i'm not sure.

Here's some code:
Code:
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear()
localfile = os.path.join(addon_dir, "resources", "assets", "somevideo.mp4")
internetfile = "www.webpage.com/externalvideo.mp4"

play_item = xbmcgui.ListItem(path=localfile)
play_item.setProperty('IsPlayable', 'true')
playlist.add(localfile, play_item)
xbmc.Player().play()

play2_item = xbmcgui.ListItem(path=internetfile)
play2_item.setProperty('IsPlayable', 'true')
playlist.add(internetfile, play2_item)

while True:
    if monitor.waitForAbort(5): # Sleep/wait for abort for 5 seconds
            # Abort was requested while waiting. We should exit
            break
    if (reproductionEnded):
        break

As you can see, the local file already exists in kodi, so it will play smoothly, and i would like to improve the experience by preloading the second item from internet while playing the local file.
Reply
#2
Kodi doesn't have a pre "cache" mechanism. You would have to download the internet file locally and queue the local copy in the playlist.

Sent from my SM-G935T
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#3
(2017-07-27, 18:52)Lunatixz Wrote: Kodi doesn't have a pre "cache" mechanism. You would have to download the internet file locally and queue the local copy in the playlist.

Sent from my SM-G935T (typie typie)

Hi, thanks for the response. I have the following idea:

Let's say i start playing the local media, and simultaneously start downloading (with python threading LINK ) the internet file.
Next, local media finishes (it is a short video file), and i add the partially downloaded internet file to the playlist.
When the local media ends playing, the internet file must have downloaded about 50 MB or so, but it is a "partial file", not a complete file.
Can i play a partial file without problems?
Does it depend on the video encoding?
Reply

Logout Mark Read Team Forum Stats Members Help
precache while playing other item in playlist0