-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.html
154 lines (150 loc) · 5.27 KB
/
3.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
<!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}}) no-repeat;
text-shadow: 0px 0px 20px #000;
background-size: cover;
overflow: hidden;
color: #fff;
}
.btn {
box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.6) !important;
}
.vol-size {
font-size: 1.3rem;
}
.radio-name {
font-size: 2rem;
font-family: 'Holtwood One SC', serif;
color: #fff;
}
.radio-buttons {
padding-top: 10px;
padding-bottom: 10px;
margin-right: 10vw;
margin-left: 10vw;
margin-top: 5vh;
background-color: rgba(255, 255, 255, 0.2);
box-shadow: 0 0 5px 1px #fff !important;
border-radius: 10px;
}
.radio-volume {
margin-left: 10vw;
margin-right: 10vw;
display: inline-block;
margin-top: 5vh;
}
.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-3">
[<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>
</button>
<button type="button" id="pause" class="btn btn-danger shadow">
<i class="far fa-pause-circle"></i>
</button>
<button type="button" id="stop" class="btn btn-warning shadow">
<i class="far fa-stop-circle"></i>
</button>
<div class="radio-volume pb-2">
<div class="form-group">
<input type="range" class="form-control-range" id="vol" value="75" maxvalue="100%">
<span class="vol-size">75%</span>
</div>
</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>
const statusText = $('.status .text');
const statusIcon = $('.status .icon');
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
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);
});
});
</script>
</body>
</html>