how to embed youtube video code example

Example 1: youtube embed video

//Author:Mohammad Arman Khan
<div>
       <iframe class="videoframe" src="https://www.youtube.com/watch?v=VfGW0Qiy2I0">
       </iframe>
</div>

Example 2: HOW TO USE A video on a html website from youtube

<iframe width="560" height="315" src="https://www.youtube.com/embed/thatthingonvideourl" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Example 3: get youtube embed code from url

<----------------------------------- HTML ---------------------------------->
YouTube ID: <span id="myId"></span>
<br />
<br />
Embed code: <pre id="myCode"></pre>

function getId(url) {
    var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
    var match = url.match(regExp);

    if (match && match[2].length == 11) {
        return match[2];
    } else {
        return 'error';
    }
}
<----------------------------------- JS ---------------------------------->
var myId = getId('http://www.youtube.com/watch?v=zbYf5_S7oJo');

$('#myId').html(myId);

$('#myCode').html('<iframe width="560" height="315" src="//www.youtube.com/embed/' + myId + '" frameborder="0" allowfullscreen></iframe>');

Example 4: embed you tube video html 5

<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>

Example 5: how to embed youtube video in html

<iframe width="420" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY">

</iframe>