Video.js: [HLS] How to temporarily stop buffering

Created on 11 Jul 2018  路  9Comments  路  Source: videojs/video.js

To save bandwidth I would like to auto pause the player and stop buffering after the tab was closed/blurred for more than 60 seconds (on a live HLS stream).

After activating the tab again I would like to resume playing.

It seem there have been similar questions without working answers:

I've tried player.pause() but that doesn't stop buffering. I've tried player.dispose() but that requires re-initializing everything (including size detection and such which is a hassle in my case).

Is there any method of pausing everything so it can be resumed later?

enhancement needs more info outdated playback

Most helpful comment

@WoLpH Did you find an answer? This seemingly trivial issue is driving me insane. Why aren't more people asking about this?

All 9 comments

Are you playing back mp4s? If so, the only real way of stopping buffering is to set the player's source to an empty string. However, browsers generally already limit how much buffering happens.
For playing back content manually via MSE, for example HLS and DASH, it may be possible to add an API that stops download when requested. We could consider such a feature request for videojs/http-streaming.

Yes, I should have mentioned that. I'm playing a HLS stream which just keeps on buffering :)

I'll move over to videojs/http-streaming

We can keep the issue here.
@forbesjo @gesinger what do you think about an API to stop buffering or is there something already that you can do in VHS?

Hey @WoLpH , the player should continue buffering until it reaches the max allowed buffer (GOAL_BUFFER_LENGTH), but then the buffering of segments should stop. We don't often see requests to pause buffering entirely as usually people aren't too concerned with filling the buffer in the background. In addition, 60 seconds is usually enough time to fill the buffer (for most bandwidth and rendition bitrate cases).

One thing that you may have noticed is that for live playlists we refresh the manifest continually (even when paused). This is because manifests are usually small in size, and it allows us to have better timing information when resuming. Was the concern mainly around live playlist refreshes?

One workaround that could be done is calling player.src to reset VHS in those instances, but let us know which part of the bandwidth you were mainly concerned with and we can take another look.

@gesinger Thank you for the detailed response, that helps a lot :)

I'll give a bit more background info in case it helps.
The reason for wanting to pause it entirely is that it's a live HLS feed of a camera using a 4G connection with limited traffic, so if the user stops watching it shouldn't keep on playing too long.

You are indeed correct about the loading. Upon further inspection it appears that it keeps on buffering video files for about a minute for me. It does continue fetching the playlists however.
In my case I'm using the playlist requests to detect whether someone is watching which means that the server keeps downloading the video over the 4G connection to make sure it's ready for the user.

Would it be easily possible to add a flag to stop loading the playlists as well? That would fix the issue quite nicely for me.

Alternatively I could somehow let the server know that the user is inactive but that's a bit trickier since the playlists still need to be built somehow.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@WoLpH Did you find an answer? This seemingly trivial issue is driving me insane. Why aren't more people asking about this?

No, besides destroying the player I haven't been able to stop the loading.

@WoLpH That's a shame. It makes the UX feel so sluggish. Thanks for your quick reply! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pblasi picture pblasi  路  3Comments

stephanedemotte picture stephanedemotte  路  4Comments

kocoten1992 picture kocoten1992  路  4Comments

zhulduz picture zhulduz  路  3Comments

askaliuk picture askaliuk  路  3Comments