-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.html
215 lines (210 loc) · 6.96 KB
/
4.html
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
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Holtwood+One+SC&display=swap">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css">
<title>Player Demo</title>
<style>
html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
-webkit-user-select: none; /* Safari */
-ms-user-select: none; /* IE 10 and IE 11 */
user-select: none; /* Standard syntax */
}
body {
background: url({{BACKGROUND}});
background-size: cover;
overflow: hidden;
}
.btn {
box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.6) !important; /* tricky */
border-color: transparent !important; /* tricky */
color: #fff;
}
.btn-success {
background-color: #0652DD;
}
.btn-warning {
background-color: #44bd32;
}
.btn-danger {
background-color: #D980FA;
}
.btn-success:hover,
.btn-success:active,
.btn-success:focus {
background-color: #0097e6;
color: #fff;
}
.btn-warning:hover,
.btn-warning:active,
.btn-warning:focus {
background-color: #009432;
color: #fff;
}
.btn-danger:hover,
.btn-danger:active,
.btn-danger:focus {
background-color: #B53471;
color: #fff;
}
.vol-size {
font-size: 1.3rem;
}
.radio-name {
font-size: 2rem;
margin-top: 5vh;
color: #1289A7;
}
.status {
color: #fff;
}
.radio-buttons {
padding-top: 10px;
padding-bottom: 10px;
margin-right: 10vw;
margin-left: 10vw;
margin-top: 10vh;
background-color: rgba(0, 162, 255, 0.5);
box-shadow: 0 0 10px 1px rgba(1, 2, 71, 0.6) !important;
border-radius: 10px;
}
.radio-volume {
color: #0652DD;
margin-left: 10vw;
margin-right: 10vw;
display: inline-block;
margin-top: 10vh;
text-shadow:
0 0 5px #FFF,
0 0 10px #FFF,
0 0 15px #FFF,
0 0 20px #49ff18,
0 0 30px #49FF18,
0 0 40px #49FF18,
0 0 55px #49FF18,
0 0 75px #49ff18,
2px 2px 2px rgba(175,44,206,0);
}
.radio-volume i {
margin-right: 10px;
font-size: 1.2rem;
}
</style>
</head>
<body>
<div class="container-fluid p-3">
<div class="text-center">
<h2 class="radio-name">{{RADIONAME}}</h2>
<p class="status mt-5">
[<span class="icon">
<i class="fas fa-info-circle"></i>
</span>]
<span class="text">Loading...</span>
</p>
<audio id="player" src="#" autoplay></audio>
<div class="radio-buttons">
<button type="button" id="play" class="btn btn-success btn-round shadow">
<i class="far fa-play-circle"></i> Play
</button>
<button type="button" id="pause" class="btn btn-danger shadow">
<i class="far fa-pause-circle"></i> Pause
</button>
<button type="button" id="stop" class="btn btn-warning shadow">
<i class="far fa-stop-circle"></i> Stop
</button>
</div>
<div class="radio-volume">
<div class="form-group">
<label for="vol">
<i class="fas fa-volume-up"></i>
</label>
<input type="range" class="form-control-range" id="vol" value="75" maxvalue="100%">
<span class="vol-size">75%</span>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.ripples/0.5.3/jquery.ripples.min.js"></script>
<script>
const statusText = $('.status .text');
const statusIcon = $('.status .icon');
const radioName = $('.radio-name');
const volSize = $('.vol-size');
const player = $('#player');
const url = "{{STREAM_URL}}";
const zeroPad = (num, places) => String(num).padStart(places, '0'); // adds zeros to numbers below than 10
const longShadow = (element, width, color) => {
let css = "";
for (var i = 1;i<width;i++){
css += `${color} ${i}px ${i}px,`;
}
css += `${color} ${width}px ${width}px`;
element.css('textShadow', css);
}
let status = false;
player.prop('volume', 0.75); // default
$(document).ready(function() {
if (player.attr('src') == '#') {
player.attr('src', url);
}
if (false === status) { // autoplay
player.get(0).play().then(function() { // can autoplay
status = true;
statusText.html('Playing...');
statusIcon.html('<i class="fas fa-volume-up"></i>');
}).catch(function() { // throws error, ask to play manual
statusText.html('Click <strong>Play</strong> to listen!');
});
}
$('#play').click(function() {
if (false === status) {
status = true;
if (player.attr('src') == '#') {
player.attr('src', url);
}
player.get(0).play();
statusText.html('Playing...');
statusIcon.html('<i class="fas fa-volume-up"></i>');
}
}),
$('#pause').click(function() {
if (true === status) {
status = false;
player.get(0).pause();
statusText.html('Paused');
statusIcon.html('<i class="fas fa-volume-mute"></i>');
}
}),
$('#stop').click(function() {
if (true === status) {
status = false;
player.attr('src', '#');
player.get(0).pause();
statusText.html('Stopped');
statusIcon.html('<i class="fas fa-volume-mute"></i>');
}
}),
$("#vol").change(function() {
let volume = $(this).val();
volSize.html(zeroPad(volume, 2) + '%');
player.prop("volume", volume / 100);
}),
$('html').ripples({ // water effects
resolution: 256,
interactive: true,
perturbance: 0.1
}),
longShadow(radioName, 15, 'rgba(0, 0, 0, 0.02)'); // long shadow effect
});
</script>
</body>
</html>