Results 1 to 3 of 3

Thread: Is this possible ?

  1. #1
    Join Date
    Sep 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Is this possible ?

    1) Script Title: Thumbnail Viewer II

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...thumbnail2.htm

    3) Describe problem:

    I was wondering if it was possible to modify this script to have thumbnail images trigger the object embed code from Youtube to display video content in the target area.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Assuming you use Youtube's embedding that generates codes like:
    Code:
    <iframe width="420" height="315" src="http://www.youtube.com/embed/nYrVLt8NavI" frameborder="0" allowfullscreen></iframe>
    ...you can just use the same technique you did with the image, but instead of the image's source, use the Youtube video's source. In the example above, it's: http://www.youtube.com/embed/nYrVLt8NavI

    Then, the quickest solution is to modify thumbnailviewer2.js into (add highlighted):
    Code:
    buildimage:function($, $anchor, setting) {
    		var imghtml='<img src="'+$anchor.attr('href')+'" style="border-width:0" />'
    		imghtml = ($anchor.attr('href').indexOf('youtube')>-1)?('<iframe width="420" height="315" src="'+$anchor.attr('href')+'" frameborder="0" allowfullscreen></iframe>'):imghtml;
    		if (setting.link)
    			imghtml='<a href="'+setting.link+'">'+imghtml+'</a>'
    		imghtml='<div>'+imghtml+((setting.enabletitle!='no' && $anchor.attr('title')!='')? '<br />'+$anchor.attr('title') : '')+'</div>'
    		return $(imghtml)
    	},
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Thumbs up

    In testing it appears one cannot fade a YouTube iframe video. But perhaps rangana's way would fade. I didn't specifically test it. If it doesn't and that's important to you, it would be easier to write a new script. Here's one way:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script type="text/javascript">
    // Video Thumb Script (c)2011 John Davenport Scheuer
    // as first seen in http://www.dynamicdrive.com/forums/
    // username: jscheuer1 - This Notice Must Remain for Legal Use
    jQuery(function($){
    	var faderate = 4000,
    	urlbase = 'http://www.youtube.com/v/',
    	urlquery = '?version=3&amp;hl=en_US&amp;rel=0;showinfo=0;controls=0;modestbranding=1;iv_load_policy=3',
    	urlregex = /\/([^\/]+)$/, urlfrag;
    	$('.vidlink').each(function(){
    		$(this).click(function(e){e.preventDefault()})
    		.bind($(this).hasClass('mouseover')? 'mouseenter' : 'click', function(){
    			if(!(urlfrag = urlregex.exec(this.href))){return;}
    			var $varea = $('#loadarea div').empty().hide().html('<object><param name="movie" value="' + urlbase +
    			urlfrag[1] + urlquery + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="opaque"></param><embed wmode="opaque" src="' + urlbase +
    			urlfrag[1] + urlquery + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"></embed></object>' +
    			'<br>' + (this.rev || ''));
    			if(window.opera){
    				$varea.show();
    			} else {
    				$varea.fadeIn(faderate);
    			}
    		});
    	});
    });
    </script>
    <style type="text/css">
    #loadarea, #loadarea object, #loadarea embed {
    	width: 420px;
    	height: 236px;
    }
    #loadarea, #loadarea div {
    	height: 261px;
    	text-align: center;
    	background-color: #eee;
    	font: bold 95% verdana, arial, sans-serif;
    }
    #loadarea {
    	margin-bottom: 3px;
    }
    </style>
    <!--[if lt IE 8]>
    <style type="text/css">
    #loadarea object, #loadarea embed {
    	margin-bottom: 3px;
    }
    </style>
    <![endif]-->
    </head>
    <body>
    <div id="loadarea"><div></div></div>
    <a class="vidlink" rev="Awsome Body Builder" href="http://youtu.be/l-CbdaTYJhs">Vid 1</a><br>
    <a class="vidlink" rev="What Gets Model Rachel Davis Off . . . the Couch" href="http://youtu.be/zGVUUnrK1-s">Vid 2</a>
    </body>
    </html>
    You can substitute img tags for the texts "Vid 1" and "Vid 2" as your thumbnail images.

    Any questions, feel free to ask.

    Notes:

    • The links are to the video, like if you click the Share button and copy the "Link to this video:" code. The urlbase and urlquery variables are then wrapped around the video's code (the last part of the "Link to this video:" url). These can be edited in the script, but I set them to values many people would want - displays the video without the suggested video at the end and without controls and with minimal promotions.

    • If you want to use mouseover activation (not recommended for video), add to the class name, example:

      Code:
      <a class="vidlink" rev="Awsome Bo . . .
      becomes:

      Code:
      <a class="vidlink mouseover" rev="Awsome Bo . . .
    • Fades in for IE, Firefox, Chrome and Safari, not Opera (the effect worked oddly in that browser). Others not tested.
    Last edited by jscheuer1; 10-02-2011 at 08:32 AM. Reason: add info and notes
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. The Following User Says Thank You to jscheuer1 For This Useful Post:

    DDmUSA (10-02-2011)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •