aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
748 stars 128 forks source link

Can this be used for web radios? #18

Open Heshyo opened 8 years ago

Heshyo commented 8 years ago

I'd like to If I have a web radio stream, can I use jsmediatags in the browser to get the info about the currently played music? And will I get updates each time a new music plays?

aadsm commented 8 years ago

They would need to send mp3 with ID3 metadata (or any other supported format). Today I don't have a file reader for streams though, can you give an example?

Heshyo commented 8 years ago

Thanks. The following stream contains the "Now playing" info (nothing else). I can see it when opening it with VLC. http://ns347811.ip-5-196-91.eu:8000/rci-zouk.mp3

aadsm commented 8 years ago

Thanks for the sample, this doesn't seem to be ID3 tags though (or any other this library supports). I've even run strings through it and didn't find anything that could be identified as an artist or title name. Do you know what metadata type is being sent in the stream?

Heshyo commented 8 years ago

No idea about the metadata type. I just used VLC to check whether the stream was containing data on top of audio. Here are some screenshots of what VLC sees, HTH: capture capture2 capture3

aadsm commented 8 years ago

I've looked into the headers and noticed this is an Icecast stream. The reason I didn't find any metadata in the stream is because a Icy-MetaData: 1 request header is needed for the server to send it. The metadata is sent on every x number of bytes streamed. I haven't tried but it should be possible to read this using the progress event that XHR emits now. The biggest issue on the browser would be using CORS, but should be possible in a node environment. I'll look into it.

This blog post explains how to read the metadata: http://www.smackfu.com/stuff/programming/shoutcast.html.

aadsm commented 8 years ago

I've played a bit on how to implement this and have a proof of concept locally (only working in node). Still need to polish the API a bit before shipping. I'm not confident I'll be able to make this work on the browser because these servers don't seem to work with CORS. The one you point to certainly doesn't.

emschwartz commented 8 years ago

@aadsm How close are you to pushing that stream reader implementation? I could use that as well, though just for reading from local file streams

emschwartz commented 8 years ago

(I'm happy to review it or help out if you need it)

Heshyo commented 8 years ago

@aadsm Thanks, I really didn't know anything about data streams before.

CORS won't cause issue in node nor in Cordova/Phonegap applications, so your work on it could also be used in hybrid apps. As for browsers, I guess most of those streams indeed don't handle CORS.

I'll see if I could provide a stream with CORS if that could help you.

aadsm commented 8 years ago

I can push the first commit I have under a branch. However, DO NOT use this in production, I will change the API :)

emschwartz commented 8 years ago

Sounds good, thanks!

On Tue, May 3, 2016 at 9:50 AM, António Afonso notifications@github.com wrote:

I can push the first commit I have under a branch. However, DO NOT use this in production, I will change the API :)

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/aadsm/jsmediatags/issues/18#issuecomment-216592793

Evan Schwartz | Software Architect | Ripple [image: ripple.com] http://ripple.com

aadsm commented 8 years ago

Btw, the way to use this is (for now):

var IcyStreamTagReader = require('./src/IcyStreamTagReader');

new IcyStreamTagReader("http://ns347811.ip-5-196-91.eu:8000/rci-zouk.mp3")
  .read({
    onUpdate: function(tags) {
      console.log(tags);
    },
    onFailure: function(error) {
      console.log('error', error);
    }
  });
Heshyo commented 8 years ago

@aadsm Thanks, I haven't had time to test it yet. But one question though: if I want to be able to listen to the stream and display the "now showing" info, should I have an audio tag plus an IcyStreamTagReader? Will I end up downloading the stream twice?

aadsm commented 8 years ago

What do you mean with audio tag? But yeah, if you play the stream in a player and use this library to read the tags you will download the stream twice because they're different apps. Ideally the player should support reading tags.

On Sunday, May 15, 2016, Heshyo notifications@github.com wrote:

@aadsm https://github.com/aadsm Thanks, I haven't had time to test it yet. But one question though: if I want to be able to listen to the stream and display the "now showing" info, should I have an audio tag plus an IcyStreamTagReader? Will I end up downloading the stream twice?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/aadsm/jsmediatags/issues/18#issuecomment-219352640

Best regards, António Afonso

Heshyo commented 8 years ago

@aadsm Yes this is what I mean. If the player supports it it's best of course. But for "now playing" metadata on a stream, we shouldn't need to download the stream forever, right? We should be able to connect, check the metadata, disconnect, then redo it eg every 5s.

BTW, what is your use of your library? It's not to display what's being played?

aadsm commented 7 years ago

@Heshyo my main usage is to display a list of songs. I don't necessarily play them.

pinpox commented 1 week ago

Any update on this? I'd like to use this aswell to show information about the current artist of a stream. I'm specifically using http://hirschmilch.de:7000/psytrance.mp3. Desktop media players show metadata like the current artist, so the information seems to be somewhere in there.