This repository has been archived by the owner on Dec 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetMusic.php
118 lines (118 loc) · 3.91 KB
/
SetMusic.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
<!DOCTYPE html>
<html id="page">
<?php
$conn = mysqli_connect("localhost", "root", "", "Music_Tap");
$id = $_GET["ID"];
$result = mysqli_query($conn, "SELECT * FROM musiclist WHERE No = " . $id);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$path = $row['Path'];
$title = $row['Title'];
}
}
else
echo "(There is no music found)";
?>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Music Tap - <?php echo $title; ?> </title>
<link rel="stylesheet" type="text/css" href="build/build.css">
<link rel="stylesheet" type="text/css" href="build/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="build/css2/SetMusic.css">
<script type="text/javascript">
var animation;
var animation1 = false;
var min = 0;
var sec = 0;
var msec = 0;
function twoDigit(integer){
if(integer < 10)
return "0" + String(integer);
return String(integer);
}
function fourDigit(integer){
if(integer < 10)
return "000" + String(integer);
else if(integer < 100)
return "00" + String(integer);
else if(integer < 1000)
return "0" + String(integer);
return String(integer);
}
document.getElementById("page").addEventListener("keypress", function(event){
var temp = String.fromCharCode(event.keyCode)
document.getElementById("hiddenText").value += twoDigit(min) + twoDigit(sec) + fourDigit(msec);
document.getElementById("hiddenText").value += temp;
document.getElementById("debugging").innerHTML = document.getElementById("hiddenText").value;
});
function tick(){
if(!animation1)
{
animation1 = true;
var elem = document.getElementById("time");
animation = setInterval(timeChange, 5);
function timeChange(){
msec += 5;
if(msec >= 1000)
{
msec -= 1000;
sec++;
}
if(sec == 60)
{
sec = 0;
min++;
}
elem.innerHTML = min + " : " + sec;
}
}
}
function stopTick(){
animation1 = false;
clearInterval(animation);
}
function playMusic(){
document.getElementById("audioBar").play();
tick();
}
function pauseMusic(){
document.getElementById("audioBar").pause();
stopTick();
}
function stopMusic(){
stopTick();
document.getElementById("audioBar").pause();
document.getElementById("audioBar").currentTime = 0;
min = 0;
sec = 0;
msec = 0;
document.getElementById("time").innerHTML = min + " : " + sec;
}
</script>
</head>
<body>
<article>
<section>
<audio id="audioBar" controls>
<source src=<?php echo "\"" . $path . "\"" ?>type="audio/mpeg">
</audio>
<div id="time" onclick="tick()">0 : 0</div>
<button class="btn btn-primary" onclick="playMusic()">Play</button>
<button class="btn btn-info" onclick="pauseMusic()">Pause</button>
<button class="btn btn-warning" onclick="stopMusic()">Stop</button>
<form action = "./SubmitKey.php" method = "GET">
<input type="hidden" name="key" id="hiddenText" value="">
<input type="hidden" name="id" value= <?php echo "\"" . $id . "\""; ?> >
<button type="submit" class="btn btn-success">Finished</button>
</form>
<p id="debugging"></p>
</section>
</article>
</body>
<script src="build/build.js"></script>
<script src="build/jquery/jquery.min.js"></script>
<script type="text/javascript" src="build/js/bootstrap.min.js"></script>
</html>