1
I have the following code:
var buttons = $('#videoGallery .vid');
var liHeight = $('#videoGallery li').height();
buttons.click(function(){
var videoID = $(this).attr('data-videoID');
var videos = $('<div id="meuVideo"> <iframe width="560" height="315" src="https://www.youtube.com/embed/'+ videoID +'?controls=0&showinfo=0" frameborder="0" allowfullscreen></iframe> </div>');
$('#meuVideo, .nowPlaying').remove();
videos.insertAfter(this).hide().slideDown("fast");
$('<span class="nowPlaying">▼ Reproduzindo ...</span>').insertAfter(this);
$('html, body').animate({
scrollTop: (videos.offset().top-liHeight)
}, 200);
});
$('#close').click(function(){
$('#meuVideo, .nowPlaying').remove();
});
#videoGallery ul {
list-style: none;
margin: 0;
padding: 0;
}
#videoGallery span {
display: block;
background-color: steelblue;
color: #fff;
font-family: sans-serif;
cursor: pointer;
padding: 4px 10px;
border-bottom: 1px solid #fff;
}
#videoGallery li {
position: relative;
}
span.nowPlaying {
position: absolute;
top: 0;
right: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id="videoGallery">
<ul>
<li><span class="vid" data-videoID="6AmRg3p79pM">Video 1</span></li>
<li><span class="vid" data-videoID="MkLFlaWxgJA">Video 2</span></li>
<li><span class="vid" data-videoID="kIhe7nFcbUg">Video 3</span></li>
<li><span class="vid" data-videoID="El3IZFGERbM">Video 4</span></li>
<li><span id="close">Fechar Tudo</span></li>
</ul>
</div>
The result can be seen here.
The way it is, you can only add Youtube videos. I would like it to be possible to add Daily Motion and UOL videos with these players:
//DailyMotion
<iframe frameborder="0" width="480" height="270" src="//www.dailymotion.com/embed/video/x3hyqc1" allowfullscreen></iframe>
//UOL
<iframe width="640" height="360" src="http://mais.uol.com.br/static/uolplayer/?mediaId=15704761" allowfullscreen frameborder="0"></iframe>
I’d like to keep it that way:
<li><span class="vid" data-videoID="6AmRg3p79pM">Video 1 - Youtube - dailymotion - Uol</span></li>
And why don’t you put it like you showed at the end of the code?
– PauloHDSousa
What do you mean? the last part of the code is how I wanted to leave it
– Endou
That’s confusing, I know the answer but I have no idea what the problem was. Create an answer and keep the question, please.
– RBoschini
The problem is that the code is only to use youtube videos. I would like to use videos from other servers that two that I mentioned in the question.
– Endou