-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
202 lines (180 loc) · 8.65 KB
/
Copy pathindex.php
File metadata and controls
202 lines (180 loc) · 8.65 KB
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
<?php
require_once 'connection.php';
$status = $mphpd->status();
?>
<!doctype html>
<html lang="en">
<head>
<!-- Kjedelige ting -->
<title> MPD Frontend </title>
<link rel="icon" href="../Pictures/Tux.svg.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<!-- Stylesheets -->
<link rel="stylesheet" href="styles/player.css">
<link rel="stylesheet" href="styles/progress_bar.css">
<link rel="stylesheet" href="styles/album_art.css">
<link rel="stylesheet" href="styles/queue_container.css">
<link rel="stylesheet" href="styles/playlist_container.css">
<link rel="stylesheet" href="styles/settings_menu.css">
<link rel="stylesheet" href="styles/transparent_mode.css">
<link rel="stylesheet" href="styles/variables.css">
<link rel="stylesheet" href="styles/mobile_friendliness.css">
<!-- Fonter og ikoner -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
<!-- Open Graph meta-tagger -->
<meta property="og:title" content="Isak Henriksen">
<meta property="og:description" content="MPD Frontend skrevet i PHP.">
<meta property="og:image" content="https://isak.brunhenriksen.no/Pictures/selfie.jpg">
<meta property="og:url" content="https://isak.brunhenriksen.no">
<meta property="og:type" content="website">
</head>
<body>
<div id="main-container">
<button id="settings-button"><i class="fa-solid fa-sliders"></i></button>
<div id="player-interact-container">
<?php
$current_song = $mphpd->player()->current_song();
if ($current_song) {
$uri = $current_song['file'];
$current_song_album = $current_song['album'] ?? "Unknown album";
$current_song_artist = $current_song['artist'] ?? "Unknown artist";
$current_song_name = $current_song['title'] ?? "Unknown title";
$volume = $current_song['volume'];
} else {
echo "It seems you're not playing anything.";
}
$binaryart = $binaryart = $mphpd->db()->read_picture($uri);
if ($binaryart) {
$base64 = base64_encode($binaryart);
echo "<img class=\"albumart\" id=\"playeralbumart\" src=\"data:image/jpeg;base64,$base64\" alt=\"Album Art\" />";
} else {
echo '<img class="albumart" id="playeralbumart" src="assets/placeholder.png" <br>';
}
?>
<div id="song-information">
<p id="song-title"><?php echo $current_song_name; ?></p>
<p id="song-artist"><?php echo "$current_song_artist ––– $current_song_album" ?></p>
</div>
<div class="progress-container">
<div id="progress-bar"></div>
</div>
<div id="time-display">0:00 / 0:00</div>
<br>
<div id="player-button-div">
<button id="previous-button"><i class="fa-solid fa-backward-step"></i></button>
<button id="skip-backwards-button"><i class="fa-solid fa-arrow-rotate-left"></i></button>
<button id="pause-button"><?php echo $status['state'] === "play" ? "<i class=\"fa-solid fa-pause\">" : "<i class=\"fa-solid fa-play\">"; ?></i></button>
<button id="skip-forwards-button"><i class="fa-solid fa-arrow-rotate-right"></i></button>
<button id="next-button"><i class="fa-solid fa-forward-step"></i></button>
<button id="volume-button">
<p id="volume-display"><?php echo "{$status['volume']}%"; ?></p><i class="fa-solid fa-volume-high"></i>
</button>
<button id="repeat-button"><?php echo $status['repeat'] === 1 ? "<i class=\"fa-solid fa-repeat\"></i>" : "<i class=\"fa-solid fa-arrows-turn-right\"></i>"; ?></button>
<button id="shuffle-button"><?php echo $status['random'] === 1 ? "<i class=\"fa-solid fa-shuffle\"></i>" : "<i class=\"fa-solid fa-arrows-rotate\"></i>"; ?></button>
</div>
</div>
</div>
<div id="queue-selector-container">
<h1 class="header">Queue</h1>
<div id='queue-song-list'>
<?php
$queue = $mphpd->queue()->get();
foreach ($queue as $queue_song) {
// info about the songs
$uri = $queue_song['file'];
$id = $queue_song['id'];
$title = $queue_song['title'];
$artist = $queue_song['artist'];
$albumart_url = "scripts/get_album_art.php?file=" . urlencode($uri);
// puts every song in a <li> inside a div so they can be controlled and viewed :D
echo "
<li>
<div class=\"queue-song\" onclick=\"play_song({$id})\">
<div class=\"queue-song-data\">
<img class=\"albumart\" id=\"queuealbumart\" loading=\"lazy\" src=\"$albumart_url\">
<div class=\"queue-song-information\">
<span class='queue-song-title'>{$title}</span> <br>
<span class='queue-song-artist'>{$artist}</span>
</div>
</div>
</div>
<div class=\"song-actions\">
<button class=\"queue-song-play-button\" onclick=\"play_song({$id})\" title=\"Play song\">
<i class=\"fa-solid fa-play\"></i>
</button>
</div>
</li>
";
}
?>
</div>
</div>
<div id="playlist-selector-container">
<h1 class="header">Playlists</h1>
<?php
$playlists = $mphpd->playlists();
foreach ($playlists as $playlist_name) {
echo "
<div id='playlist-list'>
<li>
<div class=\"playlist\" onclick=\"play_playlist('$playlist_name')\">
<div class=\"playlist-data\">
<img class=\"albumart\" id=\"queuealbumart\" src=\"./assets/placeholder.png\" alt=\"playlist\">
<div class=\"queue-song-information\">
<span class='queue-song-title'>{$playlist_name}</span> <br>
<span class='queue-song-artist'>Cool playlist</span>
</div>
</div>
</div>
</li>
</div>
";
}
?>
</div>
<!--Settings popup-->
<dialog id="settings-dialog">
<h2>Settings</h2>
<div id="settings">
<button id="close-settings-button" onclick="close_settings()"><i class="fa-regular fa-circle-xmark"></i></button>
<div class="settings-toggles" id="transparency-setting">
<p><b>Enable transparency</b><i>This enables transparency in the settings menu and in other places</i></p>
<label class="switch">
<input id="transparency-toggle" type="checkbox" onclick="toggle_transparency()">
<span class="slider round"></span>
</label>
</div>
</div>
</dialog>
<?php
// dev debugging stuff - to be removed in final build
echo $status["state"], "<br> <br>";
foreach ($current_song as $song) {
echo $song, "<br>";
}
foreach ($status as $detsomskjer) {
echo $detsomskjer;
}
echo "<br> <br>";
print_r(array_keys($current_song)); // prints out all the array keys in $current_song, since it isn't shown in any of the MphpD documentation
echo "<br>";
print_r(array_keys($status)); // prints out all the array keys in $status, since it isn't shown in any of the MphpD documentation
echo "<br>", $status['elapsed'];
$stats = $mphpd->stats();
print_r(array_keys($stats));
echo $stats['playtime'];
?>
<script src='scripts/player_controls.js'></script>
<script src='scripts/keyboard_shortcuts.js'></script>
<script src='scripts/progress_update.js'></script>
<script type='module' src='scripts/fetch_colors.js'></script>
<script src='scripts/queue_controls.js'></script>
<script src='scripts/settings_dialog.js'></script>
<script src='scripts/apply_settings.js'></script>
<script src='scripts/playlist_controls.js'></script>
</body>
</html>