Closed lexterror closed 3 years ago
To attach a visualizer, it would be best to create the audio element first with an id, and then pass it in when instantiating IcecastMetadataPlayer. This is how the React demo page works.
<audio id="audio-source"><audio/>
<script>
const player = new IcecastMetadataPlayer("https://example.com/stream", {
audioElement: document.getElementById("audio-source")
});
// use the ID of your audio element anywhere else on your webpage
<script/>
If you have multiple streams on your webpage, and you want them to all use the same audio element, you'll need to call detachAudioElement()
before creating another instance of IcecastMetadataPlayer. The demo uses the changeStation
callback that is called when another station is clicked by: first stopping the player, then calling detachAudioElement()
before creating a new instance with the new stream endpoint.
https://github.com/eshaz/icecast-metadata-js/blob/4229bade017a78a2fa2991cf093101146661b089/src/demo/src/App.js#L22-L57
It's working now!
Thank you!
Hi I'm trying to attach a visualizer to your player but Im unsure of the source name.
Thank you!