Tainted canvases may not be exported in android

509 Views Asked by At

I'm trying to use canvas to take a screenshot in the video(m3u8) that is playing and I get the following error, Error only on Android, ios and desktop web are ok.

Uncaught (in promise) DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

this is my code

const canvas = document.createElement('canvas');
canvas.width = this.videoEl.videoWidth; // this.videoEl is video element
canvas.height = this.videoEl.videoHeight;
canvas.getContext('2d')?.drawImage(this.videoEl, 0, 0, canvas.width, canvas.height);
const imgData = canvas.toDataURL('image/jpeg', 1.0);
return imgData;

And I set crossOrigin = 'Anonymous' on video Element

What should I do?

0

There are 0 best solutions below