Search code examples
c#javascriptasp.netimageopentok

Getting a snapshot image of a video using opentok


What is the parent DIV for the img? The tutorial on their website doesn't really explain anything about this code so I'm wondering how it actually works.

var imgData = publisher.getImgData();
var img = document.createElement("img");
img.setAttribute("src", "data:image/png;base64," + imgData);

// Replace with the parent DIV for the img
document.getElementById("containerId").appendChild(img);

Solution

  • parent div seems to be containerId. Somewhere in the html, you are expected to have an element with that id attribute:

    <div id="containerId"> </div>
    

    As you may know, you can display the captured snapshot without the parent id. you can simply append your img element to the document body:

    document.body.appendChild( img );

    Good Luck!