-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
132 lines (109 loc) · 2.9 KB
/
index.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
<html>
<head>
<title>227 FM</title>
<meta charset="utf-8">
<link rel="icon" type="image/png" href="favicon.png">
<script>
function reloadPlayer() {
console.log("Scheduling player reload");
document.getElementById('error').style.color = 'red';
clearPlayer();
window.playerReloadTimeoutId = setTimeout(function() {
console.log("Reloading player");
delete window.playerReloadTimeoutId;
startPlayer();
}, 500);
}
function startPlayer() {
console.log("Starting player");
document.getElementById('error').style.color = 'white';
window.player = new Audio();
window.player.onerror = reloadPlayer;
window.player.onended = reloadPlayer;
window.player.src = 'http://227fm.radiokitstream.org/227fm.mp3';
window.player.play();
}
function clearPlayer() {
window.player.onerror = undefined;
window.player.onended = undefined;
window.player.pause();
window.player.src = '';
delete window.player;
}
function stopPlayer() {
console.log("Stopping player");
if(window.playerReloadTimeoutId) {
console.log("Clearing scheduled reload");
clearTimeout(window.playerReloadTimeoutId);
delete window.playerReloadTimeoutId;
}
document.getElementById('error').style.color = 'white';
clearPlayer();
}
function togglePlayer() {
var button = document.getElementById('button');
if (button.innerHTML !== '||') {
button.innerHTML = "||";
startPlayer();
} else {
button.innerHTML = "▸";
stopPlayer();
}
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-91373360-2', 'auto');
ga('send', 'pageview');
</script>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
background: #fff;
text-align: center;
font-family: sans-serif;
}
img {
display: block;
margin: 0 auto;
}
.info {
margin: 1em 0;
}
.error {
margin: 1em 0;
color: white;
}
button {
background: #56b617;
color: #fff;
border: 0;
border-radius: 8px;
font-size: 64px;
padding: 0;
margin: 0;
padding-bottom: 10px;
height: 120px;
width: 120px;
cursor: pointer;
}
button:hover {
background: #387710;
}
</style>
</head>
<body>
<img src="logo.jpg" alt="logo">
<div class="info">
Clique ici pour regarder online radio:
</div>
<div class="error" id="error">
Erreur: Impossible de se connecter.
</div>
<button id="button" onClick="togglePlayer()">▸</button>
</body>
</html>