eshaz / icecast-metadata-js

Browser and NodeJS packages for playing and reading Icecast compatible streaming audio with realtime metadata updates.
163 stars 20 forks source link

Looking for a way to update metadata without playing #45

Closed xunkar closed 3 years ago

xunkar commented 3 years ago

Would it be possible to enable a way to receive metadata without actively playing the audio stream?

I need a simple page displaying data on the current track from my server, to be displayed as a widget on a livestream. For this to work the widget must be always active without any input from the user. This requires forcing some sort of autoplay right now, which is blocked by the chromium based browser being used, meaning no metadata event is received. I've tried setting audioElement: null when instantiating the player but it did not have the desired effect.

Thank you for your work.

eshaz commented 3 years ago

You can do this using the /status-json.xsl endpoint on your Icecast server https://icecast.org/docs/icecast-trunk/server_stats/ If you really want to, you can pull the metadata from the stream using this library; however, I would not recommend this if the client isn't playing the audio.

xunkar commented 3 years ago

That's the issue, I cannot. Only artist and title metadata appear in /status-json.xsl all other ogg tags are missing, but your player is able to retrieve them.

eshaz commented 3 years ago

You can use icecast-metadata-js instead of using icecast-metadata-player to accomplish this. You will need to fetch the stream, send the response into IcecastReadableStream, and then when the first onMetadata updates is called you can use the metadata and abort the fetch request. Simply put this code in a setInterval to repeat these steps.

lexterror commented 3 years ago

Eshaz: could you please provide a short example in javascript for the following example:

You can use icecast-metadata-js instead of using icecast-metadata-player to accomplish this. You will need to fetch the stream, send the response into IcecastReadableStream, and then when the first onMetadata updates is called you can use the metadata and abort the fetch request. Simply put this code in a setInterval to repeat these steps.

Im sure many users could benefit from this. Thank you!

eshaz commented 3 years ago

@lexterror I put an enhancement #63 that will cover this. I'll just make this a part of this library as a separate module.