HTML5: Play video from stored binary string

后端 未结 2 852
余生分开走
余生分开走 2021-02-10 07:44

I am trying to read the contents of a video file as a binary string using the FileReader.readAsBinaryString(Blob|File) as shown in the example http://www.html5rocks.com/en/tutor

2条回答
  •  生来不讨喜
    2021-02-10 08:28

    Your problem might be with the player.src

    player.src = "data:video/webm;base64,"+evt.target.result;
    

    It is expecting the data to be in base64 but you're giving it a binary string.

    Try encoding it to base64 using btoa

    player.src = "data:video/webm;base64,"+btoa(evt.target.result);
    

提交回复
热议问题