I need to give the YouTube video as a source to video tag in HTML5, once the video has finished playing "onended" event will fired in that I write some kind of script that will run.
<video id="videoSource" style="visibility:visible" width="1000" height="500" controls="controls" onended="hideVideo()">
<source src="**Youtube Video Link Goes here**" type="video/mp4" />
</video>
<script type="text/javascript">
function hideVideo() {
document.getElementById("videoSource").style.visibility="hidden";
}
</script>
Here all working fine with local video file, only thing is I need to give a YouTube video as a source it's not working so please any one knows this help me..
Html5 does not support youtube url, If you need a video src for your site you can do:
Step 1: add &html5=True
to your favorite youtube url
Step 2: Find <video/>
tag in source
Step 3: Add controls="controls"
to video tag: <video controls="controls"..../>
Example:
<video controls="controls"
class="video-stream"
x-webkit-airplay="allow"
data-youtube-id="N9oxmRT2YWw"
src="http://v20.lscache8.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cratebypass%2Coc%3AU0hPRVRMVV9FSkNOOV9MRllD&itag=43&ipbits=0&signature=D2BCBE2F115E68C5FF97673F1D797F3C3E3BFB99.59252109C7D2B995A8D51A461FF9A6264879948E&sver=3&ratebypass=yes&expire=1300417200&key=yt1&ip=0.0.0.0&id=37da319914f6616c"></video>
Note there seems to some expire
stuff. I don't know how long the src
string will work.
Still testing myself.
Note that this video src is specific to the browser you use to retrieve the page source. I think Youtube generates this HTML dynamically (at least currently) so in testing if I copy in Firefox this works in Firefox, but not Chrome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With