Notification texts go here Contact Us Buy Now!

How To Add A Youtube Video As Page Background In Blogger

How to Add a YouTube Video as Page Background in Blogger How to Add a YouTube Video as Page Background in Blogger

If you are have searched the entire web and have not found the solution on how to add a YouTube video in your Blogger blog. Then this tutorial will teach you how to do so.

You should be thankful to the JQuery plugin Tubular that allows us to use YouTube videos as a background for your Blogger blog.

Even though having a video as a background seems to look more attractive and original as well. But it has some drawbacks in it.

You can mute your background video.
If the YouTube video which you have added has ads then it will appear in your blog's background. and
It can slow down your blog loading time.



So, if you want a special reason or if your blog loads very fast then consider adding video background to your blog.

It can also be done using HTML5, but the duduk perkara with this method is that you will need to load the video in 3 different formats. Ie. Mp4, WebM, and ovg formats along with your picture for the browser that does not support the files.

Even though adding YouTube videos as a background has disadvantages, but practically I like it. So, let’s get started.

Step 1. Login to your Blogger blog and click theme/template and click on Edit HTML.

How to Add a YouTube Video as Page Background in Blogger How to Add a YouTube Video as Page Background in Blogger

Step 2. Presiding Control + F, together type </head>
tag.


How to Add a YouTube Video as Page Background in Blogger How to Add a YouTube Video as Page Background in Blogger

Step 3. Past the bellow two codes just above the </head>
tag.

Code 1.
 <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js' type='text/javascript'/>    <script type='text/javascript'>    var videoWidth = 853;     var videoRatio = 16/9;     var defaultDiv = 'wrapper-video';    jQuery.fn.tubular = function(videoId,wrapperId) {    wrapperId = (typeof(wrapperId) == undefined) ? 'wrapper-video' : wrapperId;    t = setTimeout("resizePlayer()",1000);     jQuery('html,body').css('height','100%');    jQuery('body').prepend('<div id="yt-container" style="overflow: hidden; position: fixed; z-index: 1;"><div id="ytapiplayer">You need Flash player 8+ and JavaScript enabled to view this video.</div></div><div id="video-cover" style="position: fixed; width: 100%; height: 100%; z-index: 2;"></div>');    jQuery('#' + wrapperId).css({position: 'relative', 'z-index': 99});    var ytplayer = 0;    var pageWidth = 0;    var pageHeight = 0;    var videoHeight = videoWidth / videoRatio;    var duration;    var iframe = '<iframe id="myytplayer" width="' + videoWidth + '" height="' + videoHeight + '" src="http://www.youtube.com/embed/' + videoId + '?autoplay=1&controls=0&modestbranding=1&showinfo=0&hd=1&iv_load_policy=3&version=3&wmode=transparent&loop=1&playlist=' + videoId + '" frameborder="0" allowfullscreen></iframe>';     jQuery('#ytapiplayer').html(iframe);    jQuery(window).resize(function() {    resizePlayer();    });    return this;    }    function onYouTubePlayerReady(playerId) {    ytplayer = document.getElementById("myytplayer");    ytplayer.setPlaybackQuality('medium');    ytplayer.mute();    }    function resizePlayer() {    var newWidth = jQuery(window).width();     var newHeight = jQuery(window).height();     jQuery('#yt-container, #video-cover').width(newWidth).height(newHeight);    if (newHeight > newWidth / videoRatio) {     newWidth = newHeight * videoRatio;     }    jQuery('#myytplayer').width(newWidth).height(newWidth/videoRatio);    }    //]]>    </script>   

Code 2.

 <script type='text/javascript'>    //<![CDATA[    $().ready(function() {    $('body').tubular('hxTu52UnIoA&t=2s','wrapper-video');     });    //]]>    </script>   


How to Add a YouTube Video as Page Background in Blogger How to Add a YouTube Video as Page Background in Blogger


Note – Replace the highlighted with your YouTube video code.

Step 4. The find by pressing Control + F to find the 
<body> tag or if you are using Template Designer’ template, then find the below line.


Step 5. Under either of these two, add the below code.

 <body expr:class='&quot;loading&quot; + data:blog.mobileClass'>   


Step 6. Now again search /body tag, and paste the below code before the <body> tag.

 </div>   


Kindly note that if you want your video to play soundless than choose a video that has no sounds because there is no option to mute the video.
If you are using jQuery, then remove your other versions so to avoid duplication and other issues.



Enjoy!







إرسال تعليق

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.