Canvas getImageData returning incorrect data on certain mobile devices

前端 未结 2 563
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 05:27

I am working on a canvas video player with some special features based on frames of the video. To overcome the unreliable timing in the video HTML5 tag the videos we are using h

2条回答
  •  天命终不由人
    2021-02-05 05:45

    I have been going through the same problem and just couldn't get it. I finally have the answer in my case which sounds 99% like your problem as well.

    It's the pixel density!!

    The pixel densities are different on all the devices you mentioned and the ones that have probably 1 dpr (device pixel ratio) are working correctly, whereas the others are not.

    So in my case using p5js I set the pixel density to be 1 and it worked like a charm;

    pixelDensity(1);
    

    So set it to be 1 dpr and you are most probably good to go!

    I hope this helps some people out there because I spent quite a while on this problem.

提交回复
热议问题