HTML5视频 - 暂停加载/部分加载

问题描述:

有没有办法预加载视频的一部分,但不是整个视频?我注意到有一个暂停事件表明视频预计不会下载,直到进一步的指示,但我不确定如何触发此事件?

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.

谢谢!

您可以使用XHR预取任何URL,但无法控制从客户端预取的数量。我想你可以试试这个:在XHR请求中设置一个标题,表明你想要预取多少,在服务器端读取这个标题,只向这个请求提供那么多数据。

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.