Solved

Better control over embedded youtube video

Posted on 2010-08-18
3
216 Views
Last Modified: 2012-05-10
Here is what the customer is wanting.  They want to display a 'specific' graphic on their page and when the user clicks on the graphic (one click), it will then show the embedded youtube video and start playing it in the position the graphic was located.  I asked a similiar question and was given a response that almost worked...but it requires two clicks (video doesn't start immediately).

<!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></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
      $("#image").click(function(){
            $(this).hide();
            $("#video").show();
      });
});
</script>
</head>
 
<body>
 
<img id="image" src="http://williamsexperttreeservice.com/beautiful_tree_1.jpg" width="640" height="385" alt="img" />
<div id="video" style="display:none;">
<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/OuRQMc0Sm48?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/OuRQMc0Sm48?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
</div>
</body>
</html>
0
Comment
Question by:cenetadmin
  • 2
3 Comments
 

Author Comment

by:cenetadmin
ID: 33464004
I assume I need to set the embedded code autoplay = 1 but I would guess I need to do that through the javascript otherwise the video would play when the page loads.
0
 
LVL 3

Accepted Solution

by:
grantunwin earned 500 total points
ID: 33465480
Use the follwoing code instead with autoplay enabled:
<!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></title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript"> 

$(document).ready(function(){

      $("#image").click(function(){

            $(this).hide();

            $("#video").show();

      });

});

</script>

</head>

 

<body>

 

<img id="image" src="http://williamsexperttreeservice.com/beautiful_tree_1.jpg" width="640" height="385" alt="img" />

<div id="video" style="display:none;">

<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/OuRQMc0Sm48?fs=1&amp;hl=en_US&amp;autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/OuRQMc0Sm48?fs=1&amp;hl=en_US&amp;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>

</div>

</body>

</html>

Open in new window

0
 

Author Closing Comment

by:cenetadmin
ID: 33512860
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
javascript (?) could not complete the operation  due to error 80020101 64 75
SVG Logo 4 31
Bootstrap 3 website error 14 43
iframe detection of parent window scale 20 59
Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now