This commit is contained in:
ron 2019-04-13 00:08:32 +02:00
parent a5f489691d
commit c9642ba76d
2 changed files with 55 additions and 66 deletions

View File

@ -9,26 +9,22 @@
<link rel="stylesheet" href="./assets/stylesheets/custom.css"> <link rel="stylesheet" href="./assets/stylesheets/custom.css">
</head> </head>
<body> <body>
<div id="content"> <div id="content">
<h1>Anarchy PlⒶnet Radio</h1> <h1>Anarchy PlⒶnet Radio</h1>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-sm-12 col-md-8 col-md-offset-2"> <div class="col-sm-12 col-md-8 col-md-offset-2">
<audio id="player" controls src="https://radio.anarchyplanet.org:8443/radio.ogg"></audio> <audio id="player" controls src="https://radio.anarchyplanet.org:8443/radio.ogg">
Your browser does not support the HTML5 Audio element.
</audio>
<ul id="history"></ul> <ul id="history"></ul>
<footer> <footer>
<p></p> <p></p>
</footer> </footer>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
var player = document.getElementById('player'); var player = document.getElementById('player');
var rng = Math.floor(Math.random() * 10000); var rng = Math.floor(Math.random() * 10000);
@ -47,8 +43,6 @@ function update(msg) {
}; };
function connect() { function connect() {
console.log('connecting');
var url = 'wss://radio.anarchyplanet.org/ws'; var url = 'wss://radio.anarchyplanet.org/ws';
var ws = new WebSocket(url); var ws = new WebSocket(url);
@ -63,15 +57,10 @@ function connect() {
ws.onerror = function(e) { ws.onerror = function(e) {
ws.close(); ws.close();
}; };
console.log(ws);
} }
connect(); connect();
</script> </script>
<noscript>Enable javascript for song information.</noscript>
<noscript>Please enable javascript to use the audio player.</noscript>
</body> </body>
</html> </html>

View File

@ -47,15 +47,15 @@ func main() {
} }
} }
m.Broadcast([]byte(metadata))
history.Value = metadata history.Value = metadata
history = history.Next() history = history.Next()
m.Broadcast([]byte(metadata))
}() }()
}) })
m.HandleConnect(func(s *melody.Session) { m.HandleConnect(func(s *melody.Session) {
for j := 0; j < 10; j++ { for i := 0; i < history.Len(); i++ {
if history.Value != nil { if history.Value != nil {
s.Write([]byte(history.Value.(string))) s.Write([]byte(history.Value.(string)))
} }