-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
63 lines (58 loc) · 2.03 KB
/
index.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
<?php
session_start(); // Start the session
if (!isset($_SESSION['username'])) {
// Redirect users who are not logged in to the login page
header("Location: login.php");
exit();
}
$songsDirectory = 'songs/';
$songs = scandir($songsDirectory);
shuffle($songs);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Music Player</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<h2>Welcome, <?php echo $_SESSION['username']; ?></h2>
<h3>Your Music Collection</h3>
<div id="audio-container">
<h3 id="current-song-title">No song selected</h3>
<audio id="audio-player" controls>
<source src="" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div id="controls-container">
<button id="shuffle-button">Shuffle</button>
<button id="previous-button">Previous</button>
<button id="next-button">Next</button>
</div>
<div class="search">
<input type="text" id="search-input" placeholder="Search songs...">
<button onclick="search-button">Search</button>
</div>
<ul id="song-list">
<?php
foreach ($songs as $song) {
if ($song !== '.' && $song !== '..') {
$songPath = $songsDirectory . $song; // Full path to the song
echo '<li><a href="' . $songPath . '" onclick="playSong(\'' . $songPath . '\', \'' . $song . '\'); return false;" data-song-url="' . $songPath . '" data-song-title="' . $song . '">' . $song . '</a></li>';
}
}
?>
</ul>
<h3>Your Favorites</h3>
<ul id="favorites-list">
<!-- Display favorites here -->
</ul>
<p><a href="logout.php">Logout</a></p>
</div>
<script src="js/script.js"></script>
</body>
</html>