2

Is there a way to preload a portion of a video, but not the entire thing? I noticed that there is a "suspend" event that indicates the video is expectedly not downloading until further instruction, but I'm unsure of how to trigger this event?

My goal is to preload a portion of a video without taking up all the users' bandwidth.

Thanks!

Matrym
  • 16,643
  • 33
  • 95
  • 140

1 Answers1

1

You can pre-fetch any URL with XHR, but you can't control how much it pre-fetch from the client-side. I think you can try this: set a header in the XHR request indicating how much you want to pre-fetch, read this header on the server-side and only feed that much data to this request.

Cat Chen
  • 2,387
  • 17
  • 12
  • That's an interesting idea. Do you know if XHR requests can resume previously partial downloads? Also, do you know which browsers support that? – Matrym Feb 28 '11 at 03:43
  • There's no way to resume downloading with another XHR. That's because resuming download by another request requires the support of 206 partial content on both sides. Usually only dedicated download software would implement this. That is to say, resume must be done in the same XHR. My suggestion would be imitating FTP: using one XHR connection to receive data stream while using another to tell the server to start or stop streaming. – Cat Chen Feb 28 '11 at 14:55
  • Interesting. Why can't you control how much is pre-fetched, though? Is it limited by the browser? – Ishidres Jul 23 '22 at 12:42