I am creating a thumbnail from videos when the web page is loaded, and i am using jquery to do it..
So I have 3 videos in the html -
    <video  width="320" height="240" controls poster="">
  <source src="small.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
        <video  width="320" height="240" controls poster="">
  <source src="small.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
        <video  width="320" height="240" controls poster="">
  <source src="small.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
3 Buttons and 3 image elements -
<button onclick="clicker(0)">GET0</button>
<button onclick="clicker(1)">GET1</button>
<button onclick="clicker(2)">GET2</button>
    <img id="img0">
    <img id="img1">
    <img id="img2">
Using the clicker function, I can create and add the thumbnail source from each video to each img elements . It works fine..
function clicker(i) {
  var video = $("video")[i];
  console.info(video);
  var canvas = document.createElement('canvas');
  canvas.width = 320;
  canvas.height = 240;
  var context = canvas.getContext('2d');
  context.drawImage(video, 0, 0, canvas.width, canvas.height);
  var dataURI = canvas.toDataURL('image/jpeg');
  $('#img'+i).attr("src", dataURI);
}
But when put into a forloop
for (var i = 0;  i < $("video").length; i++) {   
  var video = $("video")[i];
  console.info(video);
  var canvas = document.createElement('canvas');
  canvas.width = 640;
  canvas.height = 480;
  var context = canvas.getContext('2d');
  context.drawImage(video, 0, 0, canvas.width, canvas.height);
  var dataURI = canvas.toDataURL('image/jpeg');
  $('#img'+i).attr("src", dataURI);
}
From what I can gather, the following  canvas.toDataURL('image/jpeg');
is not running in the forloop for some reason
The image sources are just black images, and it doesn't work at all.
I can't see any difference whatsoever?
 
     
    