Stream live audio from the internet and into your soundscapes.
Have you dreamed of streaming live internet audio directly into your
soundscapes? This is Hz.StreamIn
reason for being.
There are a few types of internet radio streams:
Hz currently supports #1, mp3
and AAC
public audio streams that can
be connected to via single public URL.
let ascene = await Ascene.BeginFiber(this);
console.log("Audio scene is ready to go.");
let dac = ascene.GetDAC();
let anode = ascene.NewAnode("Hz.StreamIn"); // magically receives audio packets.
ascene.Chain(anode, dac);
await ascene.Sync();
let [host, stream] = ["https://live.radioradicale.it", "/live.mp3"];
let ret = await StreamMgr.AudioStreamOpen(host, stream, anode.GetId())
console.log(`open returned ${JSON.stringify(ret)}`);
if(ret.tid != null)
{
// Listen for 20 seconds. Streaming may take a while to
// get going.
setTimeout(async () =>
{
console.log(`closing ${ret.tid}`);
StreamMgr.AudioStreamClose(ret.tid);
await Aengine.Close();
}, 20000);
}