makes it internet radio instead!
This commit is contained in:
parent
c1f6dc323d
commit
e195725a31
@ -1,19 +1,31 @@
|
|||||||
<div id="player">
|
<div id="player">
|
||||||
<span id="player-text"></span>
|
<span id="player-text"></span>
|
||||||
<a href="javascript:void(0)" onClick="stopPlayer()">stop</a>
|
<a id="player-stop" href="javascript:void(0)">stop</a>
|
||||||
<a href="javascript:void(0)" onClick="MIDIjs.play('/assets/mid/canyon.mid')">play</a>
|
<a id="player-play" href="javascript:void(0)">play</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
var duration = 0;
|
|
||||||
function updatePlayerStatus(msg) {
|
|
||||||
document.getElementById("player-text").innerHTML = msg;
|
|
||||||
}
|
|
||||||
function stopPlayer() {
|
|
||||||
MIDIjs.stop();
|
|
||||||
document.getElementById("player-text").innerHTML = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
MIDIjs.message_callback = updatePlayerStatus;
|
<audio id="interadio" src="https://radio.erb.pw/listen/subspace/radio.mp3"></audio>
|
||||||
|
<script src='/assets/js/icystream.js'></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var player = document.getElementById('interadio');
|
||||||
|
var playertxt = document.getElementById('player-text');
|
||||||
|
console.log(player);
|
||||||
|
console.log(playertxt);
|
||||||
|
|
||||||
|
function playEr(){
|
||||||
|
player.play();
|
||||||
|
playertxt.style.display = 'inline';
|
||||||
|
};
|
||||||
|
|
||||||
|
function stopEr(){
|
||||||
|
player.pause();
|
||||||
|
playertxt.style.display = 'none';
|
||||||
|
};
|
||||||
|
|
||||||
|
stopEr();
|
||||||
|
document.getElementById('player-stop').onclick = stopEr;
|
||||||
|
document.getElementById('player-play').onclick = playEr;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ navbar: topnav
|
|||||||
<title>{{ page.title }}</title>
|
<title>{{ page.title }}</title>
|
||||||
<link rel="stylesheet" href="/assets/css/styles.css">
|
<link rel="stylesheet" href="/assets/css/styles.css">
|
||||||
<link rel="stylesheet" href="https://webcomicring.org/js/comicring.css">
|
<link rel="stylesheet" href="https://webcomicring.org/js/comicring.css">
|
||||||
<script type='text/javascript' src='//midijs.net/lib/midi.js'></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<img src="/assets/images/crt1.png" class="overlay">
|
<img src="/assets/images/crt1.png" class="overlay">
|
||||||
|
24
assets/js/icystream.js
Normal file
24
assets/js/icystream.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
async function readConstant(readableStream) {
|
||||||
|
const reader = readableStream.getReader();
|
||||||
|
const re = /StreamTitle='(.*)'/;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const { done, value } = await reader.read();
|
||||||
|
if (done) {break;}
|
||||||
|
|
||||||
|
let cur = new TextDecoder("utf-8").decode(value);
|
||||||
|
var fin = re.exec(cur);
|
||||||
|
if (!fin) { continue; }
|
||||||
|
|
||||||
|
fin = fin[1].split('\'')[0];
|
||||||
|
document.getElementById("player-text").innerHTML = fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var opts = { headers: {} };
|
||||||
|
opts["headers"]["Icy-Metadata"] = "1";
|
||||||
|
// we're using the 64kbps version to save a bit of bandwidth
|
||||||
|
let mustr = fetch("https://radio.erb.pw/listen/subspace/radio-64.mp3", opts)
|
||||||
|
mustr.then((res) => { readConstant(res.body);})
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user