Reputation: 45
I am making a website where users can provide a link to their YouTube videos while filling up a form.
How can these videos be played in an iframe or a video tag on the website without being embedded?
I have tried the following but the video is not playing inside the webpage
<iframe src='".$link."'></iframe>
//where $link = "https://www.youtube.com/watch?v=KUh2O8HylUM";
//or $link = "//www.youtube.com/watch?v=KUh2O8HylUM";
Upvotes: 0
Views: 102
Reputation: 5895
<div id="youtube_container"></div>
<script>
var link = prompt("enter youtube link");
link = link.split("v=")[1];
$("#youtube_container").html("<iframe width='854' height='480' src='https://www.youtube.com/embed/" + link + "' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>");
</script>
Upvotes: 1