Skip to content
Extraits de code Groupes Projets
Valider cdb65247 rédigé par Sybil's avatar Sybil
Parcourir les fichiers

- Tiny player included in the menu,

- Expanded player with a better integration,
- To finish : Autoplay goes to the next page.
parent 631208ad
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Aucun aperçu pour ce type de fichier
var music_info; var music_info;
var player; var player;
var player_display = false; var player_expand = false;
var player_min;
var player_max;
$( ".clickable_links" ).each(function() { $( ".clickable_links" ).each(function() {
if ($(this).data().player == "youtube" ) { if ($(this).data().player == "youtube" ) {
...@@ -25,8 +27,13 @@ function youtube_player() { ...@@ -25,8 +27,13 @@ function youtube_player() {
player_destroy(); player_destroy();
player_button(); player_button();
next_button(); next_button();
var player_height;
if (player_expand) { player_height = 390; }
else { player_height = 30; }
player = new YT.Player('player_block', { player = new YT.Player('player_block', {
height: '390', height: player_height,
width: '640', width: '640',
videoId: music_info.data().url, videoId: music_info.data().url,
events: { events: {
...@@ -35,10 +42,22 @@ function youtube_player() { ...@@ -35,10 +42,22 @@ function youtube_player() {
'onError': player_error 'onError': player_error
} }
}); });
var white_top = $("#header").height();
$("#white").css({'height':white_top}).slideDown();
player_min = 30;
player_max = 390;
} }
function next_music() { function next_music() {
music_info = $("li[data-id=\'"+music_info.data().id+"\']").next(); music_info = $("li[data-id=\'"+music_info.data().id+"\']").next();
if (music_info.length == 0) {
window.location.href = $(".next a").attr('href');
//setTimeout($(".clickable_links").first().trigger("click"),2000);
//console.log($(".clickable_links").first());
}
if (music_info.data().player == "youtube" ) { if (music_info.data().player == "youtube" ) {
youtube_player(); youtube_player();
} }
...@@ -106,8 +125,13 @@ function soundcloud_player() { ...@@ -106,8 +125,13 @@ function soundcloud_player() {
player_destroy(); player_destroy();
player_button(); player_button();
next_button(); next_button();
var player_height;
if (player_expand) { player_height = 120; }
else { player_height = 20; }
var music_url = "https://www.soundcloud.com/"+music_info.data().url; var music_url = "https://www.soundcloud.com/"+music_info.data().url;
SC.oEmbed(music_url, { auto_play: true , maxheight: 120, maxwidth: 1000 }, function(oEmbed, error) { SC.oEmbed(music_url, { auto_play: true , maxheight: player_height, maxwidth: 1000 }, function(oEmbed, error) {
if (error) { if (error) {
next_music(); next_music();
} }
...@@ -117,27 +141,36 @@ function soundcloud_player() { ...@@ -117,27 +141,36 @@ function soundcloud_player() {
setTimeout(soundcloud_listener, 2000 ); setTimeout(soundcloud_listener, 2000 );
} }
}); });
var white_top = $("#header").height();
$("#white").css({'height':white_top}).slideDown();
player_min = 20;
player_max = 120;
} }
function player_button(){ function player_button(){
if (player_display) { if (player_expand) {
$(".menu").prepend("<span><a id=\"player\">Player [Hide]</a></span>"); $(".menu").prepend("<span><a id=\"player\">Player [Reduce]</a></span>");
} }
else { else {
$(".menu").prepend("<span><a id=\"player\">Player [Show]</a></span>"); $(".menu").prepend("<span><a id=\"player\">Player [Expand]</a></span>");
} }
$("#player").on( 'click', function(){ $("#player").on( 'click', function(){
if ( player_display ) { if ( player_expand ) {
$("#player_position").css("display", "none"); $("iframe").attr('height', player_min);
$("#player").html("Player [Show]"); $("#player").html("Player [Expand]");
player_display = false; player_expand = false;
} }
else { else {
$("#player_position").css("display", "block"); $("iframe").attr('height', player_max);
$("#player").html("Player [Hide]"); $("#player_position").slideDown();
player_display = true; $("#player").html("Player [Reduce]");
} player_expand = true;
}
var white_top = $("#header").height();
$("#white").css({'height':white_top}).slideDown();
}); });
} }
......
Aucun aperçu pour ce type de fichier
...@@ -68,19 +68,18 @@ ul ...@@ -68,19 +68,18 @@ ul
} }
.menu { .menu {
margin: auto; margin: 5px auto;
text-align: center; text-align: center;
background-color: rgba(0, 110, 140, 1); background-color: rgba(0, 110, 140, 1);
} }
#white{ #white{
height: 73px; height: 63px;
} }
#header{ #header{
position:fixed; position:fixed;
width: 100%; width: 100%;
background-color: white; background-color: white;
padding: 10px 0;
margin: 0; margin: 0;
top: 0; top: 0;
} }
...@@ -103,7 +102,7 @@ body, html, head{ ...@@ -103,7 +102,7 @@ body, html, head{
} }
#player_position{ #player_position{
display: none; margin-bottom: 5px;
} }
.music_id .music_id
......
Fichier supprimé
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
<span><a href="/tags">Tags</a></span> <span><a href="/tags">Tags</a></span>
</li> </li>
</ul> </ul>
<div id="player_position"><div id="player_block"></div></div> <div id="player_position"><div id="player_block"></div></div>
</div> </div>
<%= yield %> <%= yield %>
</body> </body>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter