How to remove related videos from the end of an embedded YouTube video


YouTube displays related videos at the end of videos you have viewed. This can be useful when we are generally watching video in youtube. but this can also be annoying and problematic.

I remembered that I had seen that we can remove related videos from the end of a YouTube video.

it’s really quite easy and simple to do!

Here is a emabeded code for Video URL

< iframe width="560" height="315" src="https://www.youtube.com/embed/4ALbrJVt1u4" frameborder="0" allowfullscreen > </ iframe>

Here is a example for you tube video. just check at end of the video. it will display all related video

If you dont want to display related video at end of youtube video then just add query string “?rel=0” to the link.

Just check the following link

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

Here is a example for you tube video. just check at end of the video.

If you are using embedded YouTube video thn youtune also give option for customize the video’s appearance on your site.

The first option is a checkbox that says “Show suggested videos when the video finishes.”

Make sure that box is unchecked. If you look at the embed code, you’ll see that it adds a parameter after the video’s URL:

This is also work when you are not used embeded videos.

You just need to add a query string “?rel=0” to the link.

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

How to play iFrame embedded YouTube video on click of a button.


In a recent my project I had to show and autoplay an embedded YouTube video on click of a button.

So if you just need to play the video on click and don’t need to know when it’s ended or do other things with it, that the YouTube API allows you to do, this is the solution you are looking for:

First we need a iframe Embed Code and simple link.

<a id="playVideo" href="#">Play Youtube Video</a>

< iframe id="youtubeVideo" width="560" height="315" src="https://www.youtube.com/embed/4ALbrJVt1u4" frameborder="0" allowfullscreen > < /iframe >

Then after we need to write simple jQuery function,

which on click just extends the YouTube video source with the autoplay parameter thus plays the video.

I also prevent the link from behaving like it normally would. Simple as that.

Following script should do the trick.


	jQuery(document).ready(function() {
		jQuery('#playVideo').on('click', function(ev) {
			jQuery("#youtubeVideo")[0].src += "&autoplay=1";
			ev.preventDefault();
		});
	});

I hope this will work for you and Maybe this is useful for you in the future. 😉

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya