Seeking in HTML5 video with Chrome

前端 未结 6 1121
南旧
南旧 2020-12-08 10:48

I\'m having issues seeking in video\'s using Chrome.

For some reason, no matter what I do, video.seekable.end(0) is always 0.

When I call

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 11:30

    Work around if modifying server code is unfeasible. Make an API call for you video, then load the blob into URL.createObjectURL and feed that into the src attribute of your video html tag. This will load the entire file and then chrome will know the size of the file allowing seeking capabilities to work.

     axios.get(`${url}`, {
          responseType: "blob"
        })
          .then(function(response) {
            setVideo(URL.createObjectURL(response.data));
          })
          .catch(function(error) {
            // handle error
            console.log(error);
          });
    

提交回复
热议问题