How to prevent the player from stopping
#1
Hello,
I try to watch local video file while downloading it.
Everything seems to work fine but when the player reach a point that isnt downloaded to the video file yet, the player stops :/
How can i make the xbmc.Player() to pause the video (like buffering) instead of stopping the video?
I tought about sending the player an localhost http link that streams the file from local server but i have no idea if it will work and how to do that.

Any suggestions?
Thanks
Reply
#2
You need to give a little more information on how you have your video source set up but I really think you are over complicating things here. Why do want to do this?
Always read the Wiki, FAQ and search the forum before posting.
Read/follow the forum rules.
Reply
#3
(2015-10-11, 17:47)Dangelus Wrote: You need to give a little more information on how you have your video source set up but I really think you are over complicating things here. Why do want to do this?

I want to "stream" videos from MEGA.co.nz there is no option to preview the file in there so you must download the file to your device , since the files are encrypted i need to decrypt the file while downloading it.
I did it and everything works fine, now i want to play the video while the download continues (very similar to torrents).
The problem is when the kodi plays the video if its reaching a time point that didnt downloaded the player just stops the video like it was ended.
I want to avoid this stop and command the player instead of stopping u want it to write "buffering..." like network streams or even only pausing the video.
Reply
#4
(2015-10-11, 18:04)hybridmag Wrote:
(2015-10-11, 17:47)Dangelus Wrote: You need to give a little more information on how you have your video source set up but I really think you are over complicating things here. Why do want to do this?

I want to "stream" videos from MEGA.co.nz there is no option to preview the file in there so you must download the file to your device , since the files are encrypted i need to decrypt the file while downloading it.
I did it and everything works fine, now i want to play the video while the download continues (very similar to torrents).
The problem is when the kodi plays the video if its reaching a time point that didnt downloaded the player just stops the video like it was ended.
I want to avoid this stop and command the player instead of stopping u want it to write "buffering..." like network streams or even only pausing the video.

I really think the easiest solution is not to do this.

Kodi isn't designed for it. You are pointing it at a file source so of course it will stop when it thinks the file has ended. Maybe wait a little longer before playing back the file, wait until it is 50% done at least?

You could possibly jerry rig a network stream using VLC or something and point Kodi to it to play back the file on an ad-hoc basis but you have to ask yourself if it's really worth all the effort as opposed to just waiting for your file to finish downloading first. Smile
Always read the Wiki, FAQ and search the forum before posting.
Read/follow the forum rules.
Reply
#5
(2015-10-11, 18:25)Dangelus Wrote:
(2015-10-11, 18:04)hybridmag Wrote:
(2015-10-11, 17:47)Dangelus Wrote: You need to give a little more information on how you have your video source set up but I really think you are over complicating things here. Why do want to do this?

I want to "stream" videos from MEGA.co.nz there is no option to preview the file in there so you must download the file to your device , since the files are encrypted i need to decrypt the file while downloading it.
I did it and everything works fine, now i want to play the video while the download continues (very similar to torrents).
The problem is when the kodi plays the video if its reaching a time point that didnt downloaded the player just stops the video like it was ended.
I want to avoid this stop and command the player instead of stopping u want it to write "buffering..." like network streams or even only pausing the video.

I really think the easiest solution is not to do this.

Kodi isn't designed for it. You are pointing it at a file source so of course it will stop when it thinks the file has ended. Maybe wait a little longer before playing back the file, wait until it is 50% done at least?

You could possibly jerry rig a network stream using VLC or something and point Kodi to it to play back the file on an ad-hoc basis but you have to ask yourself if it's really worth all the effort as opposed to just waiting for your file to finish downloading first. Smile

Thats what i did.
In the addon settings i've added a bar that you can determine how much the size of the file should be to play it.
The thing is that it depends on the user's network speed, if a user will watch a movie that its size is 15gb and he will wait something like 10 minutes before playing, poor network connection will stop the video in the middle of the movie and he will get upset because now he cant even seek forward to the minute that the player stopped..
If there will be a buffering or pausing he will wait another 10 minutes and he will continue to watch the movie from the same point.
I wonder if there is a python lib that allows me to generate network stream address to the video file that can trick the kodi player and will make it to pause and buffer instead of stopping
Reply
#6
Actually, it is a very interesting technical problem and, working on my YATP torrent player plugin, I was able to solve it by implementing a feature that I called "controlled file serving". It is based on the following principles:

- My plugin includes an internal WSGI http-server that servers videofiles to Kodi via http.
- Videofiles are divided into pieces (in my case these are torrent chunks) and served piece by piece.
- Each piece is checked if it has actually been downloaded before serving it to Kodi. If a piece has not yet been downloaded, playback is paused until the piece is available.

The latter is very important. Without the ability to check if a piece is actually present you won't be able to prevent Kodi from swallowing invalid pieces into its cache.

As for implementation specifics, I used Bottle web-framework and slightly tweaked Python's built-in WSGIRef http-server. Controlled file serving is based on the fact that a WSGI server works with any iterable Python object, so I pass it a generator function that does the job.

This is a Bottle route that serves videofiles: https://github.com/romanvm/kodi.yatp/blo...pp.py#L162
This is a generator function that implements controlled file serving: https://github.com/romanvm/kodi.yatp/blo...er.py#L797

I hope you will find this info useful.Smile
Reply

Logout Mark Read Team Forum Stats Members Help
How to prevent the player from stopping0