Turn Off Light Feature For Video Streaming Site

Most of the times when you watching a streaming video from Youtube or other else, you found that all the comment or related videos or ads are little bit distracting. So if you own a video streaming website, it’s better if you can give this turn off light feature, so your visitor can enjoy their time when watching a video from your site.

To implement this turn off light feature, you need JQuery to modify CSS on the fly.

For JQuery library i’m using Ajax from Google API:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>

And for CSS class i’m using:

.lightSwitcher {
position:absolute;
z-index:101;
background-image:url(light_bulb_off.png);
background-repeat:no-repeat;
background-position:left;
padding: 0 0 0 20px;
outline:none;
text-decoration:none;}
#shadow {
background-image:url(shade1x1.png);
position:absolute;
left:0; top:0;
width:100%;
z-index:100;}
.turnedOff {
color:#ffff00;
background-image:url(light_bulb.png);
}

And here the JQuery script i’m using:

jQuery(document).ready(function(){
            jQuery("#shadow").css("height", jQuery(document).height()).hide();
            jQuery(".lightSwitcher").click(function(){
                jQuery("#shadow").toggle();
                if (jQuery("#shadow").is(":hidden"))
                    jQuery(this).html("Turn off the lights").removeClass("turnedOff");
                 else
                    jQuery(this).html("Turn on the lights").addClass("turnedOff");
            });

        });

To see the complete demo click here.

So how the code works:
When the visitor click the “Turn off the lights”, jquery will display the shadow div, which will make background shade, and then change the text to “Turn on the lights” with change the bulb icon. Where the shadow div z-index is above all except the videos and “Turn On the lights” link.

Download the script.

Comments

  1. Nepali Uphero says:

    please provide the download link .. The above is not working..

  2. Nepali Uphero says:

    Sorry Bro. Again I forgo to mention the problem

    The shadow will be masked in the whole page.

  3. Humberto says:

    hello
    Itried to use this script..got it working but when lights is turning off. then
     I Cant access the Turn lights on link…  what m'I doing wrong? 
     I place the lamp on the spot above player, and set the <div id= "shadow"></div>
     before the ending body tag and copy and paste the head code from your page in to my… I m not a advanced webmaster…   can you help me. with instructions. step by step??  thank you..  my site.. http://www.lavtv.net
    (I'm not using youtube video, could this be the problem?
     
    Thank you.
    Ps: I would like to black transparency the entire site and not just a lite shadow. if possible?
    tks

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.