forked from jjchan1/Jukebox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Currently Playing.html
153 lines (128 loc) · 6.39 KB
/
Currently Playing.html
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script type="text/javascript" src="https://www.youtube.com/iframe_api"></script>
<script>
var player;
function onYouTubeIframeAPIReady() {
var ctrlq = document.getElementById("youtube-audio");
ctrlq.innerHTML = '<img id="youtube-icon" style="height:30px; vertical-align:middle; align: center;" src=""/><div id="youtube-player"></div>';
ctrlq.style.cssText = 'cursor:pointer;cursor:hand;display:none';
ctrlq.onclick = toggleAudio;
player = new YT.Player('youtube-player', {
height: '0',
width: '0',
// videoId: ctrlq.dataset.video,
playerVars: {
autoplay: ctrlq.dataset.autoplay,
loop: ctrlq.dataset.loop,
list: 'PL6Ri1UOk51t6SCUALmklRE_7hvtyoOZJM',
listType: 'playlist',
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function togglePlayButton(play) {
document.getElementById("youtube-icon").src = play ? "pause-circular-button.png" : "play-button.png";
}
// --Hide play/pause button--
// function togglePlayButton(play) {
// document.getElementById("youtube-icon").src = play ? "" : "";
// }
function toggleAudio() {
if ( player.getPlayerState() == 1 || player.getPlayerState() == 3 ) {
player.pauseVideo();
togglePlayButton(false);
} else {
player.playVideo();
togglePlayButton(true);
}
}
function onPlayerReady(event) {
player.setPlaybackQuality("small");
document.getElementById("youtube-audio").style.display = "inline-block";
togglePlayButton(player.getPlayerState() !== 5);
}
function onPlayerStateChange(event) {
if (event.data === 0) {
togglePlayButton(false);
}
}
var songCount =0;
function addNewSong() {
var song = prompt("URL", "Enter YouTube Link");
if (song != null && song != "") {
songCount = songCount +1;
var currCount = songCount;
var box = document.createElement('div');
var listItem = document.createElement('li');
box.className = "regbox";
listItem.id = "song" + currCount;
var heartIcon = document.createElement('i');
heartIcon.className ="fa fa-heart-o";
heartIcon.style="color: white; font-size: 10px; margin-right:7px";
heartIcon.id = "icon" + currCount;
heartIcon.onclick = function() {toggleColor(heartIcon, "pink")};
box.appendChild(heartIcon);
var node = document.createTextNode("Song" + currCount);
box.appendChild(node);
var downIcon = document.createElement('i');
downIcon.className="fa fa-angle-double-down";
downIcon.style="color: white; font-size: 20px; float:right; padding-left: 20px;";
downIcon.id = "down" + currCount;
downIcon.onclick = function() {toggleColor(downIcon, "red")};
box.appendChild(downIcon);
var upIcon = document.createElement('i');
upIcon.className="fa fa-angle-double-up";
upIcon.style="color: white; font-size: 20px; float: right;";
upIcon.id = "up" + currCount;
upIcon.onclick = function() {toggleColor(upIcon, "green")};
box.appendChild(upIcon);
listItem.appendChild(box)
var element = document.getElementById("addNew");
element.appendChild(listItem);
}
}
function toggleColor(iconName, color) {
if (iconName.style.color === "white"){
iconName.style.color = color;
}
else{
iconName.style.color = "white";
}
}
</script>
</head>
<body>
<h1>JUKEBOX</h1>
<h2>Currently Playing</h2>
<center>
<div class="regbox" style="vertical-align:text-bottom; width: 65%; height:50px;">
<div data-video="pCdWnY4Dn2w" data-autoplay="1" data-loop="1" id="youtube-audio">
</div>
<span style="vertical-align: middle">Mic Drop - BTS</span><i class="fa fa-close" style="float: right; font-size: 30px;"></i>
</div>
</center>
<b style="text-align: center; padding-left: 47%;padding-right: 14%;">Up Next</b>
<a href="#"><i class="fa fa-plus-square-o" onclick=addNewSong() style="margin-top: 30px; font-size: 40px;"></i></a>
<center class="center-container" style="padding-top: 10px; padding-bottom: 10px;">
<ul id="addNew">
</ul>
</center>
</br>
<h2> Room Code: XXXXXX </h2>
<div class="nav">
<center>
<a class="a icon" href="Home.html"><i class="fa fa-home" style="font-size: 50px; padding: 15px;"></i></a>
<a class="a icon" href="Playlists.html"><i class="fa fa-music" style="font-size: 50px; padding: 15px;"></i></a>
<a class="a icon" href="Currently Playing.html"><i class="fa fa-volume-up" style="color: #4656ea; font-size: 50px; padding: 15px;"></i></a>
</center>
</div>
</body>
</html>