Friday, February 4, 2011

how to disable mouse over of a youtube video ?

If we are embedding youtube videos in our webpage, usually we can play/pause the videos. Even we will redirect to youtube video page. Normally we can’t change the properties of play/pause functionality on mouse over. But we can disable the area of the video by using css .

First embed the youtube video in our page.
<embed src="http://www.youtube.com/v/R55e-uHQna0&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
After that create a div with absolute position similar as the height and width of the video.
Set a transparent background for that div.

<style type="text/css">
#apDiv1 {
position:absolute;
width:425px;
height:350px;
background:url(transparent.png);}
</style>
<div id="apDiv1"></div>

So no event will work on the flash video file. This will be applicable for all flash videos.

Source Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Disable mouse over of a youtube video</title>
<style type="text/css">
#apDiv1 {
position:absolute;
width:425px;
height:350px;
background:url(transparent.png);}
</style>
</head>
<body>
<div id="apDiv1"></div>
<embed src="http://www.youtube.com/v/R55e-uHQna0&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>
</body>
</html>

1 comment:

  1. This was very helpful! Thank you very much!

    ReplyDelete