How do I read out the first 4 bytes in javascript, turn it into an integer and remove the rest?

前端 未结 1 1984
忘掉有多难
忘掉有多难 2021-01-25 06:16

I need to transfer webcam data over the internet from one browser to another.

The webcam is displayed in a HTML5 canvas. Then I get its dataUrl, and turn i

1条回答
  •  南笙
    南笙 (楼主)
    2021-01-25 07:16

    You can use Blob.slice() method to get bytes.
    See docs: https://developer.mozilla.org/en-US/docs/Web/API/Blob.slice

    1)

    var bytes = blob.slice(0,4);
    

    2)

    var arrayOfBytes = [];
    for(var i=0;i

    Note: I didn't test it!

    0 讨论(0)
提交回复
热议问题