Packagecom.curlyben.media
Classpublic class ID3TagReader
InheritanceID3TagReader Inheritance flash.events.EventDispatcher

An ID3 tag reader, supporting the majority of features implemented in ID3v1.0 through ID3v2.4.
The builtin ID3 reading capabillities of FlashPlayer are both limited and restricted.
ID3TagReader used in conjunction with RedHerring can help developers achieve more.


How to extract information from ID3 tags:

ID3 tags are made available when the event tagFound is captured.


Example
Setting up a tagFound event listener:
 var id3reader:ID3TagReader = new ID3TagReader();
 id3reader.addEventListener(ID3TagReader.EV_TAGFOUND, tagFoundHandler);
 
 ...
 
 private function tagFoundHandler(event:ID3Event):void {
  if(parseFloat(event.ID3Tag.version) >= 2.0)
   // handle 2.x tag
  else
   // handle 1.x tag
 }
 
The ID3Event object has the property ID3Tag which works like the builtin ID3Info class.
Property Description
ID3Tag.albumThe album title
ID3Tag.artistThe song/item artist
ID3Tag.commentThe stream name
ID3Tag.genreThe stream genre
ID3Tag.songNameThe song/item name
ID3Tag.trackThe song/item track
ID3Tag.yearThe copyright year

On ID3v2 and higher, ID3Event.ID3Tag can host a possible four extra property sets and four helper functions to help selecting custom data from those properties:

How to extract information from icecast/shoutcast tags:

Meta information from icecast/shoutcast compliant streams in packaged into an ID3Info object by ID3TagReader.

Setting up a icyMetaFound event listener:
 var id3reader:ID3TagReader = new ID3TagReader();
 id3reader.addEventListener(ID3TagReader.EV_ICYMETAFOUND, tagFoundHandler);
 
 ...
 
 private function tagFoundHandler(event:ID3Event):void {
   trace("The StreamTitle is: " + event.ID3Tag.icy_streamtitle);
  ...
 }
 
The ID3Event object has the property ID3Tag which works like the builtin ID3Info class.
On icecast/shoutcast streams, ID3Event.ID3Tag won't deliver as much information as true ID3 tags:
Property Description Available
ID3Tag.albumThe album titlesometimes
ID3Tag.artistThe song/item artistnormally
ID3Tag.commentThe stream namenormally
ID3Tag.genreThe stream genrenormally
ID3Tag.songNameThe song/item namenormally
ID3Tag.trackThe song/item tracksometimes
ID3Tag.yearThe copyright yearno
ID3Tag.icy_urlThe server webpagenormally
ID3Tag.icy_streamurlThe live item webpagenormally
ID3Tag.icy_streamtitleThe live item titlenormally

Because FlashPlayer doesn't currently provide any access to its underlying sound API, and there are limited practical methods to inspect raw sound channel data, the icyMetaFound event will only be triggered when a developers code calls the ReadTag method.
Future versions of FlashPlayer may allow direct stream inspection. Until that time, when dealing with meta information in icecast/shoutcast streams - developers must programatically make calls to ReadTag to guarantee up to date information.

Footnotes:
1 Developers are encouraged to modify RedHerring to prevent foreign domain abuse.
Imposing downstream limits and filtering HTTP methods and addresses are also recommended practice.
2 Extended headers are not currently implemented.
No in the wild scenario explored during development of version 1.x has seen the ID3v2.x Extended Header in use.
As no proprietary software is currently available that creates such frames, incorporating them into ID3TagReader has been posponed.
3 According to ID3v2.3 and ID3v2.4, URL link frames are supposed to include both a URL and a description that accompany and describe said link. However, after testing over 200 MP3 files which featured such frames in development, none actually contained both attributes. Development continued with this defacto format for URL link frames, but won't cause any problem should an accurate specification frame be processed.



Public Methods
 MethodDefined by
  
Creates an instance of ID3TagReader.
ID3TagReader
  
ClearCache():void
Clears the tag cache.
ID3TagReader
  
InspectCache(res_url:String):ID3Info
Returns a copy of a cached ID3Info object.
ID3TagReader
  
ReadTag(url:URLRequest, redherring:String = null):void
Reads any ID3 tags in the specified resource.
ID3TagReader
Events
 EventSummaryDefined by
   This event is triggered when an ID3v2 version 3+ extended header is found.ID3TagReader
   This event is triggered when a icecast/shoutcast meta block is found and available.ID3TagReader
   This event is triggered when no ID3 tag information is available for a resource.ID3TagReader
   This event is triggered when a tag is found to be damaged, corrupt or otherwise unusable.ID3TagReader
   This event is triggered when an ID3 tag is found and available.ID3TagReader
Public Constants
 ConstantDefined by
  EV_EXTENDED_NI : String = "extendedNotImplemented"
[static] Defines the value of the type property of an extendedNotImplemented event object.
ID3TagReader
  EV_ICYMETAFOUND : String = "icyMetaFound"
[static] Defines the value of the type property of an icyMetaFound event object.
ID3TagReader
  EV_NOTAGFOUND : String = "noTagFound"
[static] Defines the value of the type property of an noTagFound event object.
ID3TagReader
  EV_TAGERROR : String = "tagError"
[static] Defines the value of the type property of an tagError event object.
ID3TagReader
  EV_TAGFOUND : String = "tagFound"
[static] Defines the value of the type property of an tagFound event object.
ID3TagReader
Constructor detail
ID3TagReader()constructor
public function ID3TagReader()

Creates an instance of ID3TagReader.

Method detail
ClearCache()method
public function ClearCache():void

Clears the tag cache.
Because of the non-blocking behaviour of ReadTag, ID3TagReader keeps a Dictionary of pending read requests internally.
This Dictionary can be cleared programmatically in case developers require the abillity to purge expired MP3 ID3Tag data.

InspectCache()method 
public function InspectCache(res_url:String):ID3Info

Returns a copy of a cached ID3Info object.

Parameters
res_url:String — The URL of the cached object to find.

Returns
ID3Info — A copy of the cached object, null if no such object is cached.
ReadTag()method 
public function ReadTag(url:URLRequest, redherring:String = null):void

Reads any ID3 tags in the specified resource.

Parameters
url:URLRequest — A URLRequest pointing to the resource containing ID3 tags.
 
redherring:String (default = null) — A URL pointing to a RedHerring proxy to use to handle the read request.
A side effect of the static nature of the RedHerring URL within the com.curlyben namespace is that setting a RedHerring URL in any com.curlyben class will also change the RedHerring address those classes will use.
Event detail
extendedNotImplementedevent 
Event object type: com.curlyben.events.ID3Event

This event is triggered when an ID3v2 version 3+ extended header is found. Parsing ID3v2 extended headers is not performed by this version of ID3TagReader.

icyMetaFoundevent  
Event object type: com.curlyben.events.ID3Event

This event is triggered when a icecast/shoutcast meta block is found and available.
For information about working with tags see: How to extract information from icecast/shoutcast tags

noTagFoundevent  
Event object type: com.curlyben.events.ID3Event

This event is triggered when no ID3 tag information is available for a resource.

tagErrorevent  
Event object type: com.curlyben.events.ID3Event

This event is triggered when a tag is found to be damaged, corrupt or otherwise unusable.

tagFoundevent  
Event object type: com.curlyben.events.ID3Event

This event is triggered when an ID3 tag is found and available.
For information about working with tags see: How to extract information from ID3 tags

Constant detail
EV_EXTENDED_NIconstant
public static const EV_EXTENDED_NI:String = "extendedNotImplemented"

Defines the value of the type property of an extendedNotImplemented event object.

EV_ICYMETAFOUNDconstant 
public static const EV_ICYMETAFOUND:String = "icyMetaFound"

Defines the value of the type property of an icyMetaFound event object.
For information about working with tags see: How to extract information from icecast/shoutcast tags

EV_NOTAGFOUNDconstant 
public static const EV_NOTAGFOUND:String = "noTagFound"

Defines the value of the type property of an noTagFound event object.

EV_TAGERRORconstant 
public static const EV_TAGERROR:String = "tagError"

Defines the value of the type property of an tagError event object.

EV_TAGFOUNDconstant 
public static const EV_TAGFOUND:String = "tagFound"

Defines the value of the type property of an tagFound event object.
For information about working with tags see: How to extract information from ID3 tags