Stop Loading Video Stream
SpeakWind opened this issue · comments
What do you want to do with Hls.js?
How can I limit the playback time of a video stream?
Perhaps I could not figure out the library settings and this can be done at the time of creating an instance of the class. If not, then I will further describe what I have already tried to do to solve my issue and why these solutions are not entirely suitable.
Playback is controlled with the HTMLMediaElement, not HLS.js.
Perhaps I could not figure out the library settings and this can be done at the time of creating an instance of the class
See the API docs for the list of configuration options: https://github.com/video-dev/hls.js/blob/master/docs/API.md
While there are settings to configure playback start and buffer length, there are none that limit playback.
If not, then I will further describe what I have already tried to do to solve my issue and why these solutions are not entirely suitable.
Can you describe in more detail what you would like to do?
I meant to do something like thing that hls.stopLoad() does.. I tried using this method.
But this method stops loading both the fragment and the playlist. So I ran into several problems.
The playlist is loaded first, then the fragment is loaded
Here are the details of the latest playlist
At this point, the video duration becomes longer than the specified limit and the download stops.
Here are the details of the latest fragment
The user presses pause. Loading playlists and fragments looks like this.
The problem is the same as in the first case, but it looks more clear. And another question appeared. What needs to be done to continue downloading video fragments despite the pause?
And finaly. It is possible that the fragment managed to load before hls.stopLoad() was executed.
Here's the playlist
Here's the fragment
The player looks like this. Playback cannot reach the end of the time period.
In all three cases, the player displays a spinner. And it looks like infinity loading.
So I need to upload a video fragment with a specified duration.
Is this information enough?
Hi @SpeakWind,
The screenshots and comments above look like a sort of snapshot of what you've tried, but I am having a hard time translating it all into functional requirements that I can help you with. Really what I wanted was for you to clarify what you meant by "limit the playback time" in plain terms we could both understand.
hls.stopLoad()
stops loading of all HLS assets belonging to those in the URL passed to hls.loadSource(URL)
. It has no bearing on playback. HLS.js will stop loading and appending/buffering assets, and when playback reaches the end of the buffer, playback will stall (spinner) unless the end of stream has been appended/buffered.
Are you trying to simply pause() playback after it reaches a certain point, or are you looking to override duration so that playback stops when it reaches a point earlier than the duration of the HLS asset you are streaming with HLS.js?
Yes. I need override duration. Playback should stop naturally when it reaches the end of the fragment. Visually, it should look as if the entire video fragment has played and there is nothing left to watch.
That is not a feature of HLS.js.
However, it could be achieved by manipulating the LevelDetails on LEVEL_UPDATED (modify details.totalduation
and remove items from the end of details.fragments
). HLS.js always attempts to use all parsed playlist content, so augmenting this data is the only way to have it behave as if it were not there to begin with.