Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Loading Video Stream #6368

Open
SpeakWind opened this issue Apr 21, 2024 · 6 comments
Open

Stop Loading Video Stream #6368

SpeakWind opened this issue Apr 21, 2024 · 6 comments

Comments

@SpeakWind
Copy link

SpeakWind commented Apr 21, 2024

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.

@SpeakWind SpeakWind added Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. Question labels Apr 21, 2024
@robwalch
Copy link
Collaborator

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?

@robwalch robwalch added Need info and removed Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Apr 22, 2024
@SpeakWind
Copy link
Author

SpeakWind commented Apr 23, 2024

I meant to do something like thing that hls.stopLoad() does.. I tried using this method.
image
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

image

Here are the details of the latest playlist

image

At this point, the video duration becomes longer than the specified limit and the download stops.
Here are the details of the latest fragment

image

The player looks like this
image image

The user presses pause. Loading playlists and fragments looks like this.

image

image image

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.

image

Here's the playlist

image

Here's the fragment

image

The player looks like this. Playback cannot reach the end of the time period.
image

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.

@robwalch robwalch added the Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. label Apr 23, 2024
@SpeakWind
Copy link
Author

Is this information enough?

@robwalch
Copy link
Collaborator

robwalch commented May 3, 2024

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?

@SpeakWind
Copy link
Author

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.

@robwalch
Copy link
Collaborator

robwalch commented May 3, 2024

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.

@robwalch robwalch added answered and removed Need info Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants