Get MP3 ID3 metadata and song length using AudioStreamer

I am using Matt Gallagher AudioStreamer to play MP3 over HTTP. I need to know the length of the song and the ID3 tags.

Can this be implemented in AudioStreamer and how?

+2


source to share


2 answers


From the Docs :

Limited Scope

 One point should be before I continue: the class is for audio streaming. By streaming, I don't mean just "audio file transferred over HTTP". Instead, I mean an endless endless HTTP source that goes on endlessly (e.g. radio station, no song).

This seems to mean that the duration can be tight.



Here's how to get ID3v2 tags:

Get Metadata

 The simplest source of metadata comes from HTTP headers. Inside the handleReadFromStream: EventType: method, use CFReadStreamCopyProperty to copy the kCFStreamPropertyHTTPResponseHeader property from CFReadStreamRef, then you can use CFHTTPMessageCopyAllHeaderFields to copy the header fields from the response. For many streaming audio servers, the stream name is one of these fields.

A much more complex source of metadata is ID3 tags. ID3v1 - always at the end of the file (so useless when streaming). ID3v2 - located at the beginning, so there may be more available.

I have never read ID3 tags, but I suspect that if you cache the first few hundred kilobytes of a file somewhere when it loads, open that cache with AudioFileOpenWithCallbacks and then read the kAudioFilePropertyID3Tag with AudioFileGetProperty you might be able to read ID3 data (if it exists ). As I said, I've never done this, so I don't know for sure if this will work.

+2


source


MP3 streams are divided into "frames", which are unitary units of data. Some streams add a block of ID3 metadata every few frames that you could theoretically scan and read.



See here for more information: http://jicyshout.sourceforge.net/oreilly-article/java-streaming-mp3-pt2/java-streaming-mp3-pt2.html

+1


source







All Articles