hip1/po/albuminfo.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function playPreview(song_id, name){
document.getElementById('songName').innerHTML = name+":"
var song = document.getElementById('song')
song.src="songs/"+song_id+".mp3"
song.controls = true
song.load
download = document.getElementById('file')
download.href = "songs/"+song_id+".mp3"
download.download = name
}
</script>
</head>
<body>
<div><a href='index.php'>Return to search</a></div>
<div>
<div id='songName'></div>
<audio id='song'>
<source src="" type="audio/mp3">
</audio>
<div><a id="file" href="" download> Download audio </a></div>
</div>
<?php
include('../db.php');
include('functions.php');
#Display page name
$album_id = $_GET['album_id'];
$query = "select * from songs where song_id = (select min(song_id) from songs where album_id = $album_id)";
$result = mysqli_query($db, $query) or die(mysqli_error($db));
$row = mysqli_fetch_array($result);
echo "<script type='text/javascript'>
playPreview($row[song_id], '$row[name]')
</script>";
$query1 = "select * from albums where album_id = $album_id";
$result1 = mysqli_query($db, $query1) or die(mysqli_error($db));
$row1 = mysqli_fetch_array($result1);
echo "<h1><a href=albums.php?band_id=$row1[band_id]>$row1[name]</a></h1>";
$query2 = "select * from songs where album_id = $album_id order by side, song_id";
$result2 = mysqli_query($db, $query2) or die(mysqli_error($db));
while($row2 = mysqli_fetch_array($result2)){
$timestring = duration($row2['seconds']);
echo "<h4>$row2[name] ";
if(file_exists("songs/$row2[song_id].mp3")){
echo "<button onClick='playPreview($row2[song_id], \"$row2[name]\")' id='previewButton'>Switch song</button>";
}
echo "</h4><div>Duration: $timestring</div>";
if ($row2['side']) {
echo "Side: $row2[side]";
}
}
function duration($seconds){
$minutes = intdiv($seconds, 60);
$seconds = $seconds % 60;
if($seconds < 10){
$seconds = "0$seconds";
}
if($minutes >= 60){
$hours = intdiv($minutes, 60);
$minutes = $minutes % 60;
$timestring = "$hours:";
}
return $timestring .= "$minutes:$seconds";
}
?>
<div id='musicEmbed'></div>
</body>
</html>
Resultaat
Made by Thijs Aarnoudse