使用用户

时间:2018-06-07 11:40:57

标签: javascript html

尝试使用用户使用html输入选择的视频中的帧创建img元素。该文件在“if”中输入,但只显示表格中的黑色方块和文件名称,而不是视频中的帧。

if(fileList[i].type === "video/"+Video[j]){  

    var video = document.createElement('video');
    video.src=(window.URL.createObjectURL(fileList[i]).replace('blob:',''));
    video.pause();
    video.muted = true;
    video.playsInline = true;
    video.play();

    var canvas = document.createElement('canvas');
        canvas.width = 50;
        canvas.height = 50;
        canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);

    var dataURI = canvas.toDataURL('image/png');

视频表

        for( var lV=0; lV<100; lV++ ){  
            // if for name
        if(fileList[i].name===NameFile[lV]){    

    var Vx = document.createElement("Table");
    Vx.setAttribute("id", "galeriaV" + (i));
    document.body.appendChild(Vx);

视频图像

    var VImg = document.createElement("tr");
    VImg.setAttribute("id", "VTr" +(i));
    document.getElementById("galeriaV" +(i)).appendChild(VImg);

    var ImgV = document.createElement("td");
    var imagV =document.createElement("img");
    imagV.setAttribute("id", "imageID" +(i));
    imagV.setAttribute("className", "bordered");

      imagV.src = dataURI;
      imagV.height = 50;
      imagV.with = 50;

    imagV.setAttribute("src","http://placehold.it/200/200/pink/black");
    imagV.setAttribute("onclick","imgClick(this)");


    ImgV.appendChild(imagV);
    document.getElementById("VTr" + (i)).appendChild(ImgV);

文件名

    var yV = document.createElement("tr");
    yV.setAttribute("id", "VNTr" + (i));
    document.getElementById("galeriaV" +(i)).appendChild(yV);

    var Vz = document.createElement("td");
    var Vt = document.createTextNode(NameFile[lV]);
    Vz.appendChild(Vt);
    document.getElementById("VNTr" + (i)).appendChild(Vz);
}// fim if name
        }   
    }   

0 个答案:

没有答案