Friday, October 2, 2015

Youtube: autoplay and disable related videos

In this article today I am going to explain how to set the video autoplay and disable the related video option.

Description:

I have embed a video https://www.youtube.com/watch?v=vOncd4pEErw in asp.net application. I want this video be auto play means when page load it start playing and want to hide the related video option.

Implementation:

To hide the related videos:
To embed the video go to Youtube video URL and scroll down. You see the share option below the video title, click on it.

Youtube: autoplay and disable related videos

There options are available Share, Embed and email. You have to choose the 2nd one (Embed), click on it. 
Youtube: autoplay and disable related videos

Below textbox you see option Show more, click on it and uncheck the “Show suggested videos when the video finishes” option.

Youtube: autoplay and disable related videos


You see an iframe code in textbox. Copy it and paste where you want to display the Youtube Video.


Example:
<iframe width="560" height="315" src="https://www.youtube.com/embed/vOncd4pEErw?rel=0" frameborder="0" allowfullscreen></iframe>

To set the video Autoplay:
Add the ?autoplay=1 to the video src in iframe code.

Example:
<iframe width="560" height="315" src="https://www.youtube.com/embed/vOncd4pEErw??autoplay=1" frameborder="0" allowfullscreen></iframe>

To set the video autoplay and hide the related video:
To implement this add the ?rel=0&autoplay=1 to video src in iframe code.

Example:
<iframe width="560" height="315" src="https://www.youtube.com/embed/vOncd4pEErw?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>

HTML Markup of webform:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <iframe width="560" height="315" src="https://www.youtube.com/embed/vOncd4pEErw?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>
    </div>
    </form>
</body>
</html>

Save the webform.Run it and check the result.

  In this article we have learn to how to set the youtube video autoplay and disable related videosI hope you enjoyed this article.

No comments:

Post a Comment