-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay.htm
More file actions
158 lines (153 loc) · 5.12 KB
/
play.htm
File metadata and controls
158 lines (153 loc) · 5.12 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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MPD player</title>
</head>
<body>
<style>
body {
background-color: black;
}
audio {
width: 100%;
}
img {
image-rendering: high-quality;
position: center;
width: 400px;
height: auto;
}
@media screen and (max-width: 800px) {
img {
image-rendering: high-quality;
width: 100%;
height: auto;
}
}
h1 {
margin-left: 10px;
white-space: pre-wrap;
font-weight:bold;
font-family:sans-serif;
background: linear-gradient(to bottom, #cbddf2, #fcebd7);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 400% 400%;
-webkit-animation: Groove 42s ease infinite;
-moz-animation: Groove 42s ease infinite;
animation: Groove 42s ease infinite;
}
@media screen and (min-width: 1000px) {
h1 {
position: fixed;
top:10px;
margin-left: 420px;
white-space: pre-wrap;
font-weight:bold;
font-family:sans-serif;
background: linear-gradient(to bottom, #cbddf2, #fcebd7);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 400% 400%;
-webkit-animation: Groove 42s ease infinite;
-moz-animation: Groove 42s ease infinite;
animation: Groove 42s ease infinite;
}
audio {
width: 70%;
}
}
@-webkit-keyframes Groove {
0%{background-position:17% 0%}
50%{background-position:84% 100%}
100%{background-position:17% 0%}
}
@-moz-keyframes Groove {
0%{background-position:17% 0%}
50%{background-position:84% 100%}
100%{background-position:17% 0%}
}
@keyframes Groove {
0%{background-position:17% 0%}
50%{background-position:84% 100%}
100%{background-position:17% 0%}
}
/*
h1 {
background-image: linear-gradient(to bottom, #cbddf2, #fcebd7);
}
*/
</style>
<script type="text/javascript">
streamPort = "8000";
infoTxt = "";
infoUrl = "";
imgUrl = "";
function dirname(path) {
return path.match(/.*\//);
}
function setUrls() {
params = new URLSearchParams(document.location.search.substring(1));
if (params.get("sp") != null){
streamPort = params.get("sp");
}
loc = window.location;
host = loc.hostname;
port = loc.port;
path = dirname(loc.pathname);
streamUrl = "http://" + host + ":" + streamPort;
if (port == ""){
imgUrl = "http://" + host + path + 'cover.jpg';
infoUrl = "http://" + host + path + 'last';
}
else {
imgUrl = "http://" + host + ":" + port + path + 'cover.jpg';
infoUrl = "http://" + host + ":" + port + path + 'last';
}
audio = document.createElement('audio');
audio.controls = true;
audio.type = 'audio/mp3';
audio.preload = 'auto';
audio.baseURI = streamUrl;
audio.src = streamUrl;
var i = document.getElementById("info");
i.appendChild(audio);
}
function toggleFullScreen() {
var i = document.getElementById("coverart");
var m = document.getElementById("info");
var requestFullScreen = i.requestFullscreen || i.mozRequestFullScreen || i.webkitRequestFullScreen || i.msRequestFullscreen;
var cancelFullScreen = document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen || document.msExitFullscreen;
if(!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
requestFullScreen.call(m);
}
else {
cancelFullScreen.call(document);
}
}
async function updateSongInfo(t) {
let res = await fetch(infoUrl, {cache: "reload"});
if(res.ok){
let infoTxt = await res.text();
epoch = Date.now();
document.getElementById('songinfo').innerHTML = infoTxt;
}
}
function updateInfo(){
epoch = Date.now();
document.getElementById('coverart').src = imgUrl + "?time=" + epoch;
updateSongInfo(epoch);
}
function refresh(){
setUrls();
document.getElementById('coverart').addEventListener("click", toggleFullScreen);
setInterval("updateInfo();",600);
}
window.onload = refresh;
</script>
<div id="info">
<img src="cover.jpg" id="coverart"></img>
<h1 id="songinfo" itemprop="0"></h1>
</div>
</body>
</html>