Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,

i am using d3.js for creating dynamc slideshow. Texts and Images work correctly but on the other hand i dont know how could i append video. Any idea?

JavaScript
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
....
<script>

var svg = d3.select("#content")
                .append("svg").
                .attr("width", "900px")
                .attr("height", "400px");

 var canvas = svg.append("g");

 canvas.append("image")
        .attr("x", 20)
        .attr("y", 125)
        .attr("height", "50px")
        .attr("width", "50px")
        .attr("xlink:href", "imageee.png");


 canvas.append("text")
        .text("hello")
        .attr("x", 145)
        .attr("y", 74)
        .style("fill", "yellow")
        .attr("font-size", 14);
...


What I have tried:

i am tying append video as a iframe, but doesnt work

JavaScript
function appendIframe() {

canvas.append("iframe")
        .attr("x", 100)
        .attr("y", 50)
        .attr("height", "315px")
        .attr("width", "560px")
        .attr("src", "https://www.youtube.com/embed/n5NcCoa9dDU")
        .attr("frameborder","0");


        alert("nice");

}

appendIframe();


</script>



Alert me "nice", but i dont see it in d3 canvas.
Posted
Updated 16-Jun-16 20:49pm
Comments
Richard Deeming 13-Apr-16 10:14am    
You can't put an <iframe> inside a <canvas>.
Member 12456835 14-Apr-16 7:09am    
I am using D3, coud you give me some example?

1 solution

You could use
HTML
<video></video>
element...but if you need video WITHIN canvas element you need some positioning magic.


Here is good link with examples[^]


And here is another one[^]


Easily googled.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900