2017-07-27, 18:38
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:
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.
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.