See if it fits. Uses the same principle of buttons:I imagine that this example can satisfy youI merged the two previous examples:var buttons = $('ul li');
var videos = $('#videoGallery div');
var titles = $('#videoGallery div h3');
var iframe = $('#videoGallery iframe');
var urls = [
"https://www.youtube.com/embed/6AmRg3p79pM?enablejsapi=1",
"https://www.youtube.com/embed/MkLFlaWxgJA?enablejsapi=1",
"https://www.youtube.com/embed/kIhe7nFcbUg?enablejsapi=1",
"https://www.youtube.com/embed/El3IZFGERbM?enablejsapi=1",
"https://www.youtube.com/embed/6AmRg3p79pM?enablejsapi=1",
"https://www.youtube.com/embed/MkLFlaWxgJA?enablejsapi=1",
"https://www.youtube.com/embed/kIhe7nFcbUg?enablejsapi=1",
"https://www.youtube.com/embed/El3IZFGERbM?enablejsapi=1"
]
buttons.on('click', function (e) {
var index = buttons.get().indexOf(this);
var videoIndex = videos.eq(index);
iframe.attr("src", urls[index])
buttons.removeClass("selected")
$(this).toggleClass("selected")
videos.removeClass('yesDisplay');
videoIndex.toggleClass('yesDisplay');
$('body').animate({scrollTop:(videoIndex.offset().top)}, 200);
});.video {
display:none;
}
.yesDisplay {
display:block !important;
}
img{
height: 80px
}
ul{
margin: 0;
padding: 0;
}
ul li{
display: block;
height: 30px;
line-height: 30px;
background: #333333;
margin: 0;
cursor: pointer;
padding-left: 10px;
color: #ffffff;
}
ul li:hover{
background: #666666;
color: #ffffff;
}
.selected{
background: #cccccc;
color: #333;
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="videoGallery">
<ul>
<li>Vídeo 01</li>
<li>Vídeo 02</li>
<li>Vídeo 03</li>
<li>Vídeo 04</li>
<li>Vídeo 05</li>
<li>Vídeo 06</li>
<li>Vídeo 07</li>
<li>Vídeo 08</li>
</ul>
<div class="yesDisplay video">
<h3>Vídeo 01</h3>
<img src="http://www.keenthemes.com/preview/metronic/theme/assets/global/plugins/jcrop/demos/demo_files/image1.jpg" alt="">
<p>Este é o vídeo 1:</p>
</div>
<div class="video">
<h3>Vídeo 02</h3>
<img src="http://goo.gl/ytbJn8" alt="">
<p>Este é o vídeo 2:</p>
</div>
<div class="video">
<h3>Vídeo 03</h3>
<img src="http://www.last-video.com/wp-content/uploads/2013/11/superbe-image-de-poissons-sous-l-eau.jpg" alt="">
<p>Este é o vídeo 3:</p>
</div>
<div class="video">
<h3>Vídeo 04</h3>
<img src="http://joombig.com/demo-extensions1/images/gallery_slider/Swan_large.jpg" alt="">
<p>Este é o vídeo 4:</p>
</div>
<div class="video">
<h3>Vídeo 05</h3>
<img src="http://www.conceptcarz.com/images/Citroen/2010-Citroen-Survolt-Concept-Image-01.jpg" alt="">
<p>Este é o vídeo 5:</p>
</div>
<div class="video">
<h3>Vídeo 06</h3>
<img src="http://i1008.photobucket.com/albums/af201/visuallightbox/Butterfly/8-1.jpg" alt="">
<p>Este é o vídeo 6:</p>
</div>
<div class="video">
<h3>Vídeo 07</h3>
<img src="http://michaeldaviddesign.com/themes/escape/files/stacks_image_85.jpg" alt="">
<p>Este é o vídeo 7:</p>
</div>
<div class="video">
<h3>Vídeo 08</h3>
<img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcS_grGhfAqTFlVrVmKC3HJ9R6CuXPfgz6U6ikgOnfgHxiu38c13" alt="">
<p>Este é o vídeo 8:</p>
</div>
<iframe width="560" height="315" src="https://www.youtube.com/embed/6AmRg3p79pM?controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>You can realize that it will load well quickly, since as I said in the comment the other elements load quickly. And that’s what happens, it doesn’t load all the videos, but od other html elements. There's only one iframe and that's the one will change yours src by clicking on some button. The others (image and text, in my example) will change with the corresponding video.Other examplesFirst caseFirst, to get the feat of pausing the video of youtube from the iframe, you must replace the ?controls=0&showinfo=0 by ?enablejsapi=1 at the end of the urls of your videos, for this will be possible to use api that enables these functions.With this just select the iframe desired with the attribute contentWindow and apply to it the: .postMessage('{"event":"command","func":"pauseVideo","args":""}', '')
// pauseVideo - outra opção seria o playVideo
And for the video to appear as at first: .postMessage('{"event":"command","func":"' + 'stopVideo' + '","args":""}', '');
In the latter case, the ?enablejsapi=1 should be added after &version=3&playerapiid=ytplayer.Example working: http://jsfiddle.net/SamirChaves/qhe7gfd3/4/ Second caseIt is worth remembering that this API is your own. Each host (Vimeo, Uol, Dailymotion, Youtube...) will have its own. As can be observed in this example: https://css-tricks.com/play-button-youtube-and-vimeo-api/ .Entering, there is a generic way to stop the videos regardless of their origins. Just reset yours src. This will only serve to stop, as has already been said. However, it will require greater performance and make the appearance of the video not instantaneous.In the example below video 01 belongs to Vimeo, already video 02 belongs to Dailymotion and load normally. For that, in your iframe you must capture the code for the embed in the area aimed at this on the host site itself.Example: http://jsfiddle.net/SamirChaves/qhe7gfd3/7/ Third caseI created one array with the urls of each video. Then I came to us the same way iframes by means of index of the buttons.var buttons = $('ul li');
var videos = $('#videoGallery div');
var titles = $('#videoGallery div p');
var iframe = $('#videoGallery div iframe');
var urls = [
"https://www.youtube.com/embed/6AmRg3p79pM?enablejsapi=1",
"https://www.youtube.com/embed/MkLFlaWxgJA?enablejsapi=1",
"https://www.youtube.com/embed/kIhe7nFcbUg?enablejsapi=1",
"https://www.youtube.com/embed/El3IZFGERbM?enablejsapi=1"
]
function pauseVideo() {
var iframes = document.getElementsByTagName("iframe");
iframes[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
}
buttons.on('click', function() {
var index = buttons.get().indexOf(this);
var videoIndex = videos.eq(index);
titles.html("Vídeo " + (parseFloat(index)+1));
iframe.attr("src", urls[index])
$('body').animate({
scrollTop: (videos.offset().top)
}, 200);
buttons.removeClass("selected")
$(this).toggleClass("selected")
pauseVideo();
});.yesDisplay {
display: block !important;
}
ul {
margin: 0;
padding: 0;
}
ul li {
display: block;
height: 30px;
line-height: 30px;
background: #333333;
margin: 0;
cursor: pointer;
padding-left: 10px;
color: #ffffff;
}
ul li:hover {
background: #666666;
color: #ffffff;
}
.selected {
background: #cccccc;
color: #333;
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="videoGallery">
<ul>
<li>Vídeo 01</li>
<li>Vídeo 02</li>
<li>Vídeo 03</li>
<li>Vídeo 04</li>
</ul>
<div class="yesDisplay">
<p>Video 1</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/6AmRg3p79pM?enablejsapi=1" frameborder="0" id="IframeVideo1" allowfullscreen></iframe>
</div>
</div>