IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

jQuery Discussion :

Supersized - lancer une vidéo en cliquant sur un slide


Sujet :

jQuery

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    115
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2005
    Messages : 115
    Points : 50
    Points
    50
    Par défaut Supersized - lancer une vidéo en cliquant sur un slide
    Bonjour à tous,

    J'ai utilisé le script "supersized.3.0.js" pour créer une galerie de photos, qui fonctionne bien.

    Par contre, j'aimerais ajouter une vidéo dans ce slideshow pour pouvoir regrouper dans un seul album les photos et les vidéos.
    J'ai essayé en ajoutant un slide avec un lien vers " .swf" au lieu de ".jpg" mais ça ne fonctionne pas. J'ai aussi essayé en mettant une image et en faisant passer dans l'url la vidéo pour la faire démarrer au clic mais ça ne fonctionne pas non plus.

    Avez-vous des idées pour que je puisse lancer la vidéo à partir d'un slide directement et que le slideshow puisse reprendre automatiquement une fois que la vidéo est finie?

    Merci beaucoup!

    Voici le code javascript de la galerie:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
    $(function(){
    	$.fn.supersized.options = {  
            startwidth: 1280,  
    	startheight: 742,
    	vertical_center: 1,
    	slideshow: 1,
    	navigation: 1,
    	thumbnail_navigation: 0,
    	transition: 0,
    	pause_hover: 0,
    	slide_counter: 1,
    	slide_captions: 1,
    	slide_interval: 600000,
    	slides : [
    	{image : './slides/slide_1.jpg', title : '', url : ''},
    	{image : './slides/slide_photo1.jpg', title : '', url : ''},
    	{image : './slides/slide_photo2.jpg', title : '', url : ''},
    	{image : './slides/slide_photo3.jpg', title : '', url : ''},
    	{image : './slides/slide_photo4.jpg', title : '', url : ''}
    	]
    	};
    $('#supersized').supersized(); 
    });
    Le code pour l'effet "supersized":
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
     
    (function($){
     
    	//Resize image on ready or resize
    	$.fn.supersized = function() {
     
     
    		$.inAnimation = false;
    		$.paused = false;
     
    		var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
    		$.currentSlide = options.start_slide - 1;
     
    		/******Set up initial images -- Add class doesnt work*****/
    		//Set previous image
    		var imageLink = (options.slides[options.slides.length - 1].url) ? "href='" + options.slides[options.slides.length - 1].url + "'" : "";
    		$("<img/>").attr("src", options.slides[options.slides.length - 1].image).appendTo("#supersized").wrap("<a " + imageLink + "></a>");//Doesnt account for start slide
     
    		//Set current image
    		imageLink = (options.slides[$.currentSlide].url) ? "href='" + options.slides[$.currentSlide].url + "'" : "";
    		$("<img/>").attr("src", options.slides[$.currentSlide].image).appendTo("#supersized").wrap("<a class=\"activeslide\" " + imageLink + "></a>");
     
    		//Set next image
    		imageLink = (options.slides[$.currentSlide + 1].url) ? "href='" + options.slides[$.currentSlide + 1].url + "'" : "";
    		$("<img/>").attr("src", options.slides[$.currentSlide + 1].image).appendTo("#supersized").wrap("<a " + imageLink + "></a>");
     
    		$(window).bind("load", function(){
     
    			$('#loading').hide();
    			$('#supersized').fadeIn('fast');
     
    			$('#controls-wrapper').show();
     
    			if (options.thumbnail_navigation == 1){
     
    				/*****Set up thumbnails****/
    				//Load previous thumbnail
    				$.currentSlide - 1 < 0  ? prevThumb = options.slides.length - 1 : prevThumb = $.currentSlide - 1;
    				$('#prevthumb').show().html($("<img/>").attr("src", options.slides[prevThumb].image));
     
    				//Load next thumbnail
    				$.currentSlide == options.slides.length - 1 ? nextThumb = 0 : nextThumb = $.currentSlide + 1;
    				$('#nextthumb').show().html($("<img/>").attr("src", options.slides[nextThumb].image));
     
    			}
     
    			$('#supersized').resizenow();
     
    			if (options.slide_captions == 1) $('#slidecaption').html(options.slides[$.currentSlide].title);//*********Pull caption from array
    			if (options.navigation == 0) $('#navigation').hide();
    			if (options.thumbnail_navigation == 0){ $('#nextthumb').hide(); $('#prevthumb').hide(); }
     
    			//Slideshow
    			if (options.slideshow == 1){
    				if (options.slide_counter == 1){ //Initiate slide counter if active
    					$('#slidecounter .slidenumber').html(options.start_slide);
    	    			$('#slidecounter .totalslides').html(options.slides.length); //*******Pull total from length of array
    	    		}
    				slideshow_interval = setInterval(nextslide, options.slide_interval);
     
    				if (options.thumbnail_navigation == 1){
    					//Thumbnail Navigation
    					$('#nextthumb').click(function() {
    				    	if($.inAnimation) return false;
    					    clearInterval(slideshow_interval);
    					    nextslide();
    					    if(!($.paused)) slideshow_interval = setInterval(nextslide, options.slide_interval);
    					    return false;
    				    });
    				    $('#prevthumb').click(function() {
    				    	if($.inAnimation) return false;
    				        clearInterval(slideshow_interval);
    				        prevslide();
    				       	if(!($.paused)) slideshow_interval = setInterval(nextslide, options.slide_interval);
    				        return false;
    				    });
    					}
     
    				if (options.navigation == 1){ //Skip if no navigation
    					$('#navigation a').click(function(){  
       						$(this).blur();  
       						return false;  
       					});
     
    					//Slide Navigation
    				    $('#nextslide').click(function() {
    				    	if($.inAnimation) return false;
    					    clearInterval(slideshow_interval);
    					    nextslide();
    					    if(!($.paused)) slideshow_interval = setInterval(nextslide, options.slide_interval);
    					    return false;
    				    });
    				    $('#prevslide').click(function() {
    				    	if($.inAnimation) return false;
    				        clearInterval(slideshow_interval);
    				        prevslide();
    				        if(!($.paused)) slideshow_interval = setInterval(nextslide, options.slide_interval);
    				        return false;
    				    });
    				    $('#nextslide').mousedown(function() {
    					   	$(this).attr("src", "images/forward.png");
    					});
    					$('#nextslide').mouseup(function() {
    					    $(this).attr("src", "images/forward_dull.png");
    					});
    					$('#nextslide').mouseout(function() {
    					    $(this).attr("src", "images/forward_dull.png");
    					});
     
    					$('#prevslide').mousedown(function() {
    					    $(this).attr("src", "images/back.png");
    					});
    					$('#prevslide').mouseup(function() {
    					    $(this).attr("src", "images/back_dull.png");
    					});
    					$('#prevslide').mouseout(function() {
    					    $(this).attr("src", "images/back_dull.png");
    					});
     
    				    //Play/Pause Button
    				    $('#pauseplay').click(function() {
    				    	if($.inAnimation) return false;
    				    	var src = ($(this).attr("src") === "images/play.png") ? "images/pause.png" : "images/play.png";
          					if (src == "images/pause.png"){
          						$(this).attr("src", "images/play.png");
          						$.paused = false;
    					        slideshow_interval = setInterval(nextslide, options.slide_interval);  
    				        }else{
    				        	$(this).attr("src", "images/pause.png");
    				        	clearInterval(slideshow_interval);
    				        	$.paused = true;
    				        }
          					$(this).attr("src", src);
    					    return false;
    				    });
    				    $('#pauseplay').mouseover(function() {
    				    	var imagecheck = ($(this).attr("src") === "images/play_dull.png");
    				    	if (imagecheck){
          						$(this).attr("src", "images/play.png"); 
    				        }else{
    				        	$(this).attr("src", "images/pause.png");
    				        }
    				    });
     
    				    $('#pauseplay').mouseout(function() {
    				    	var imagecheck = ($(this).attr("src") === "images/play.png");
    				    	if (imagecheck){
          						$(this).attr("src", "images/play_dull.png"); 
    				        }else{
    				        	$(this).attr("src", "images/pause_dull.png");
    				        }
    				        return false;
    				    });
    				}
    			}
    		});
     
    		$(document).ready(function() {
    			$('#supersized').resizenow(); 
    		});
     
    		//Pause when hover on image
    		$('#supersized').hover(function() {
    	   		if (options.slideshow == 1 && options.pause_hover == 1){
    	   			if(!($.paused) && options.navigation == 1){
    	   				$('#pauseplay').attr("src", "images/pause.png"); 
    	   				clearInterval(slideshow_interval);
    	   			}
    	   		}
    	   		if($.inAnimation) return false; //*******Pull title from array
    	   	}, function() {
    			if (options.slideshow == 1 && options.pause_hover == 1){
    				if(!($.paused) && options.navigation == 1){
    					$('#pauseplay').attr("src", "images/pause_dull.png");
    					slideshow_interval = setInterval(nextslide, options.slide_interval);
    				} 
    			}
    				//*******Pull title from array
    	   	});
     
    		$(window).bind("resize", function(){
        		$('#supersized').resizenow(); 
    		});
     
    		$('#supersized').hide();
    		$('#controls-wrapper').hide();
    	};
     
    	//Adjust image size
    	$.fn.resizenow = function() {
    		var t = $(this);
    		var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
    	  	return t.each(function() {
     
    			//Define image ratio
    			var ratio = options.startheight/options.startwidth;
     
    			//Gather browser and current image size
    			var imagewidth = t.width();
    			var imageheight = t.height();
    			var browserwidth = $(window).width();
    			var browserheight = $(window).height();
    			var offset;
     
    			//Resize image to proper ratio
    			if ((browserheight/browserwidth) > ratio){
    			    t.height(browserheight);
    			    t.width(browserheight / ratio);
    			    t.children().height(browserheight);
    			    t.children().width(browserheight / ratio);
    			} else {
    			    t.width(browserwidth);
    			    t.height(browserwidth * ratio);
    			    t.children().width(browserwidth);
    			    t.children().height(browserwidth * ratio);
    			}
    			if (options.vertical_center == 1){
    				t.children().css('left', (browserwidth - t.width())/2);
    				t.children().css('top', (browserheight - t.height())/2);
    			}
    			return false;
    		});
    	};
     
    		//Slideshow Next Slide
    	function nextslide() {
    		if($.inAnimation) return false;
    		else $.inAnimation = true;
    	    var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
     
    		var currentslide = $('#supersized .activeslide');
    	    currentslide.removeClass('activeslide');
     
    	    if ( currentslide.length == 0 ) currentslide = $('#supersized a:last'); //*******Check if end of array?
     
    	    var nextslide =  currentslide.next().length ? currentslide.next() : $('#supersized a:first'); //*******Array
    	    var prevslide =  nextslide.prev().length ? nextslide.prev() : $('#supersized a:last'); //*******Array
     
    		$('.prevslide').removeClass('prevslide');
    		prevslide.addClass('prevslide');
     
    		//Get the slide number of new slide
    		$.currentSlide + 1 == options.slides.length ? $.currentSlide = 0 : $.currentSlide++;
     
    		/**** Image Loading ****/
    		//Load next image
    		loadSlide=false;
    		$.currentSlide == options.slides.length - 1 ? loadSlide = 0 : loadSlide = $.currentSlide + 1;
    		imageLink = (options.slides[loadSlide].url) ? "href='" + options.slides[loadSlide].url + "'" : "";
    		$("<img/>").attr("src", options.slides[loadSlide].image).appendTo("#supersized").wrap("<a " + imageLink + "></a>");
     
    		if (options.thumbnail_navigation == 1){
    		//Load previous thumbnail
    		$.currentSlide - 1 < 0  ? prevThumb = options.slides.length - 1 : prevThumb = $.currentSlide - 1;
    		$('#prevthumb').html($("<img/>").attr("src", options.slides[prevThumb].image));
     
    		//Load next thumbnail
    		nextThumb = loadSlide;
    		$('#nextthumb').html($("<img/>").attr("src", options.slides[nextThumb].image));
    		}
     
    		currentslide.prev().remove(); //Remove Old Image
     
    		/**** End Image Loading ****/
     
    		//Display slide counter
    		if (options.slide_counter == 1){
    		    $('#slidecounter .slidenumber').html($.currentSlide + 1);//**display current slide after checking if last
    		}
     
    		//Captions
    	    if (options.slide_captions == 1){
    	    	(options.slides[$.currentSlide].title) ? $('#slidecaption').html(options.slides[$.currentSlide].title) : $('#slidecaption').html('') ; //*******Grab next slide's title from array
    	    }
     
    	    nextslide.hide().addClass('activeslide')
    	    	if (options.transition == 0){
    	    		nextslide.show(); $.inAnimation = false;
    	    	}
    	    	if (options.transition == 1){
    	    		nextslide.fadeIn(750, function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 2){
    	    		nextslide.show("slide", { direction: "up" }, 'slow', function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 3){
    	    		nextslide.show("slide", { direction: "right" }, 'slow', function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 4){
    	    		nextslide.show("slide", { direction: "down" }, 'slow', function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 5){
    	    		nextslide.show("slide", { direction: "left" }, 'slow', function(){$.inAnimation = false;});
    	    	}
    	    $('#supersized').resizenow();
    	}
     
    	//Slideshow Previous Slide
    	function prevslide() {
    		if($.inAnimation) return false;
    		else $.inAnimation = true;
    		var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
     
    	    var currentslide = $('#supersized .activeslide');
    	    currentslide.removeClass('activeslide');
     
    	    if ( currentslide.length == 0 ) currentslide = $('#supersized a:first');
     
    	    var nextslide =  currentslide.prev().length ? currentslide.prev() : $('#supersized a:last'); //****** If equal to total length of array
    	    var prevslide =  nextslide.next().length ? nextslide.next() : $('#supersized a:first');
     
    		//Get current slide number
    		$.currentSlide == 0 ?  $.currentSlide = options.slides.length - 1 : $.currentSlide-- ;
     
    		/**** Image Loading ****/
    		//Load next image
    		loadSlide=false;
    		$.currentSlide - 1 < 0  ? loadSlide = options.slides.length - 1 : loadSlide = $.currentSlide - 1;
    		imageLink = (options.slides[loadSlide].url) ? "href='" + options.slides[loadSlide].url + "'" : "";
    		$("<img/>").attr("src", options.slides[loadSlide].image).prependTo("#supersized").wrap("<a " + imageLink + "></a>");
     
    		if (options.thumbnail_navigation == 1){
    		//Load previous thumbnail
    		prevThumb = loadSlide;
    		$('#prevthumb').html($("<img/>").attr("src", options.slides[prevThumb].image));
     
    		//Load next thumbnail
    		$.currentSlide == options.slides.length - 1 ? nextThumb = 0 : nextThumb = $.currentSlide + 1;
    		$('#nextthumb').html($("<img/>").attr("src", options.slides[nextThumb].image));
    		}
     
    		currentslide.next().remove(); //Remove Old Image
     
    		/**** End Image Loading ****/
     
    		//Display slide counter
    		if (options.slide_counter == 1){
    		    $('#slidecounter .slidenumber').html($.currentSlide + 1);
    		}
     
    		$('.prevslide').removeClass('prevslide');
    		prevslide.addClass('prevslide');
     
    		//Captions
    	    if (options.slide_captions == 1){
    	    	(options.slides[$.currentSlide].title) ? $('#slidecaption').html(options.slides[$.currentSlide].title) : $('#slidecaption').html('') ; //*******Grab next slide's title from array
    	    }
     
    	    nextslide.hide().addClass('activeslide')
    	    	if (options.transition == 0){
    	    		nextslide.show(); $.inAnimation = false;
    	    	}
    	    	if (options.transition == 1){
    	    		nextslide.fadeIn(750, function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 2){
    	    		nextslide.show("slide", { direction: "down" }, 'slow', function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 3){
    	    		nextslide.show("slide", { direction: "left" }, 'slow', function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 4){
    	    		nextslide.show("slide", { direction: "up" }, 'slow', function(){$.inAnimation = false;});
    	    	}
    	    	if (options.transition == 5){
    	    		nextslide.show("slide", { direction: "right" }, 'slow', function(){$.inAnimation = false;});
    	    	}
     
    	    	$('#supersized').resizenow();//Fix for resize mid-transition
    	}
     
    	$.fn.supersized.defaults = { 
    			startwidth: 4,  
    			startheight: 3,
    			vertical_center: 1,
    			slideshow: 1,
    			navigation:1,
    			thumbnail_navigation: 0,
    			transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
    			pause_hover: 0,
    			slide_counter: 1,
    			slide_captions: 1,
    			slide_interval: 5000,
    			start_slide: 1
    	};
     
    })(jQuery);
    Merci à tous ;-)

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    115
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2005
    Messages : 115
    Points : 50
    Points
    50
    Par défaut
    Bonjour,

    Je reviens vers vous pour voir si quelqu'un aurait une idée pour m'aider car je suis toujours coincée au même niveau

    Merci à tous

Discussions similaires

  1. cliquer sur un lien pour lancer une vidéo
    Par GégéMétal dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 06/07/2012, 15h06
  2. [POO] Comment lancer un son en cliquant sur une image
    Par zebra123 dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 29/01/2009, 21h10
  3. lancer une macro en cliquant sur un texte
    Par Bubale dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 13/05/2008, 13h18
  4. Est-il possible de mettre en pause une vidéo en cliquant sur un hyperlien
    Par kouedic dans le forum Balisage (X)HTML et validation W3C
    Réponses: 1
    Dernier message: 24/04/2008, 17h20
  5. Comment trier une DBGRID en cliquant sur une colonne
    Par sessime dans le forum Bases de données
    Réponses: 8
    Dernier message: 09/10/2004, 16h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo