-
Notifications
You must be signed in to change notification settings - Fork 3
/
Currently Playing.php
245 lines (210 loc) · 9.07 KB
/
Currently Playing.php
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
<?php
require("methods.php");
session_start();
if (!isset($_SESSION['username'])) {
$username = "Test Username";
} else {
$username = $_SESSION['username'];
}
$onload = "";
$db_songs = connectSongs();
if (isset($_GET["playlistName"])){
$pName = $_GET["playlistName"];
$top = "
<li>
<div>Add Songs to Get Started</div>
</li>";
$code = "emptyparty";
}else{
$pName = "Best of Kendrick Lamar";
$top = "<li>
<div data-video='pCdWnY4Dn2w' data-autoplay='1' data-loop='1' id='youtube-audio'></div>
<span>Kendrick Lamar- DUCKWORTH.</span>
</li>";
$code = "kdot";
}
$songs = getSongs($db_songs, $pName);
if ($songs){
foreach ($songs as &$s){
$title = $s[1];
$onload .= "addNewSong(\"$title\"); ";
}
}
$db_songs->close();
$body = <<<BODY
<!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">
<link href='https://fonts.googleapis.com/css?family=Codystar' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Lobster Two' rel='stylesheet'>
<link href='https://fonts.googleapis.com/css?family=Marvel' rel='stylesheet'>
<script type="text/javascript" src="https://www.youtube.com/iframe_api"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
var count = 0;
var player;
var videoList = ['T3xwtb5Sm6E', '2lzXpOF5Ssg'];
window.onload = function(){
$onload
}
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,
// listType: 'playlist',
// list: 'PL_Cqw69_m_yzbMVGvQA8QWrL_HdVXJQX7', //BTS
// list: 'PLnsTUgMW5W__4eI0349Lu64ljXsrRjhwJ'
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function togglePlayButton(play) {
document.getElementById("youtube-icon").src = play ? "pause.png" : "play.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.loadVideoById(videoList[count]);
player.setPlaybackQuality("small");
document.getElementById("youtube-audio").style.display = "inline-block";
togglePlayButton(player.getPlayerState() !== 5);
}
function onPlayerStateChange(event) {
if (event.data === 0) {
count++;
// togglePlayButton(false);
player.loadVideoById(videoList[count]);
}
}
var songCount = 0;
function addSong(){
var song = prompt("Song Name or URL:", "Enter Song Name or URL");
ajaxAdd(song);
}
function ajaxAdd(name){
$.ajax({
url: 'ajaxAdd.php',
type: 'post',
data: { songname: '' + name, roomcode: 'Best of Kendrick Lamar'},
success: function(data){
addNewSong(data);
}
});
}
function addNewSong(song) {
if (song != null && song != "") {
songCount = songCount + 1;
var currCount = songCount;
var box = document.createElement('div');
var listItem = document.createElement('li');
box.className = "list-item-container";
listItem.id = "song" + currCount;
var heartIcon = document.createElement('i');
heartIcon.className ="fa fa-heart-o";
heartIcon.style="color: black; font-size: 30px; margin-right:7px; line-height: 50px";
heartIcon.id = "icon" + currCount;
heartIcon.onclick = function() {toggleColor(heartIcon, "#f4428f")};
box.appendChild(heartIcon);
// var node = document.createTextNode("Song" + currCount);
var node = document.createTextNode(song);
box.appendChild(node);
var upIcon = document.createElement('i');
upIcon.className="fa fa-angle-double-up";
upIcon.style="color: black; font-size: 35px; position: absolute; right: 10px; line-height: 50px;";
upIcon.id = "up" + currCount;
upIcon.onclick = function() {toggleColor(upIcon, "#0bf406")};
box.appendChild(upIcon);
var downIcon = document.createElement('i');
downIcon.className="fa fa-angle-double-down";
downIcon.style="color: black; font-size: 35px; position: absolute; right: 40px; line-height: 50px;";
downIcon.id = "down" + currCount;
downIcon.onclick = function() {toggleColor(downIcon, "red")};
box.appendChild(downIcon);
listItem.appendChild(box)
var element = document.getElementById("addNew");
element.appendChild(listItem);
}
}
function toggleColor(iconName, color) {
if (iconName.style.color === "black"){
iconName.style.color = color;
}
else{
iconName.style.color = "black";
}
}
</script>
</head>
<body>
<section class="container topnav">
<center>
<a class="icon" style="position: fixed; left: 0;"><i class="fa fa-user-circle-o" style="color: black;">
<section class="container topnavtext">
$username
</section>
</i></a>
<a class="icon" href="Login.php" style="position: fixed; right: 0;"><i class="fa fa-sign-out">
<section class="container topnavtext">
Logout
</section>
</i></a>
</center>
</section>
<section class="container header">
<h1>JUKEBOX</h1>
<h2>Currently Playing</h2>
<h2>Room Code: $code</h2>
</section>
<section class="container list item-list">
<ul>
$top
</ul>
</section>
<section class="container header">
<h2>Up Next
<a href="#"><i class="fa fa-plus-square-o" onclick=addSong() style="font-size: 40px;"></i>
</a>
</h2>
</section>
<section class="container list item-list">
<ul id="addNew">
</ul>
</section>
</br>
<section class="container nav">
<center>
<a class="icon" href="Home.php"><i class="fa fa-home"></i></a>
<a class="icon" href="Manage Playlists.php"><i class="fa fa-list"></i></a>
<a class="icon" href="Currently Playing.php"><i class="fa fa-play" style="color: #FFFFFF;"></i></a>
</center>
</section>
</body>
</html>
BODY;
echo $body;
?>