Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

What to do in such a case - failed to execute 'todataurl' on 'htmlcanvaselement': tainted canvases may not be exported.

Asked by David Edwards Mar 6, 2023 1.7K views 1 answer
Share

About this question

I'm trying to create a thumbnail for the video using plyr - https://github.com/sampotts/plyr I can get the blob as in the below codepen: https://codepen.io/suryaiiit/pen/LeZwgr But when I try the same in the VF, it is giving error.

: false, Options: { } }; setTimeout(function() { var instances = plyr.setup({ // Output to console //debug: true }); }, 2000); function getThumb() { console.log('getThumb') var video = document.getElementById('video'); var w = video.videoWidth;//video.videoWidth * scaleFactor; var h = video.videoHeight;//video.videoHeight * scaleFactor; var canvas = document.createElement('canvas'); canvas.width = w; canvas.height = h; var ctx = canvas.getContext('2d'); ctx.drawImage(video, 0, 0, w, h); document.getElementById("preview").appendChild(canvas); var data = canvas.toDataURL("image/jpg"); console.log('canvas data: ', data); } [removed] 

I get the below error:

thum:50 Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. at getThumb

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.