Media_GetMetadata ( containerOrFile { ; tag { ; getTagsAsCodes } } )
This variant of Media_GetMetadata is intended for sound. For the image variant of the function please refer here.
Media_GetMetadata lets you view the ID3 metadata stored in an MP3 sound file. You can either view the entire list of ID3 tags, or a specific tag, like “Artist,” etc.
Parameter | Description |
---|---|
containerOrFile |
Location of the sound file. The container parameter can be:
|
tag | Optional parameter. If you want to view only a specific piece of information. Tags can be referred to by name or by code (see below). The following names are supported:
|
getTagsAsCodes | Optional parameter. Return MP3 tags as their codes rather than names when set to “true” or 1. |
List all Metadata Values
Set Field [ MyTable::Metadata ;
Media_GetMetadata ( containerOrFile ) ]
When the optional “tag” parameter is left blank or unused, Media_GetMetadata returns all of the ID3 metadata, such as:
Name: Poème, Op. 41, No. 6
Album: Piano Encores: 50 Favourite Pieces (Disc 2)
Year: 1995
Genre: Classical
Extracting Values from a List of Tags and Values
To extract the value of a particular tag, use the Media_ExtractInfo function. Note: It is not recommended to parse information list by hand as it may contain encoded characters.
Returning a Single Tag Value
If you don’t want the entire metadata list and you know the name of a particular value you want, you can specify the tag directly with Media_GetMetadata:
Set Field [ MyTable::Metadata ;
Media_GetMetadata (
containerOrFile ;
"Year"
) ]
For a sound file with the metadata shown above, MediaManager will respond with “1995”.
List all Metadata Values using ID3 tags
Set Field [ MyTable::Metadata ;
Media_GetMetadata (
containerOrFile ;
"" ; # "" = all tags
True # get @codes
) ]
When the second parameter is set to blank quotes (“”) and the third parameter is set to “True”, Media_GetMetadata returns all of the metadata using their corresponding ID3 codes, such as:
@TIT2: Poème, Op. 41, No. 6
@TALB: Piano Encores: 50 Favourite Pieces (Disc 2)
@TYER: 1995
@TCON: Classical
Returning a Single Tag Value using ID3 tags
Set Field [ MyTable::Metadata ;
Media_GetMetadata (
containerOrFile ;
"@TYER" ; # TYER ID3 Frame
True # use @codes
) ]
For a sound file with the metadata shown above, MediaManager will respond with “1995”.
To use ID3 tags directly with this function, the “@” character must precede the standard ID3 code (“TYER” = year) and the third parameter must be set to True or 1.
To see the full list of ID3 tags currently in use within a file’s metadata, follow the instructions above to list all metadata values using ID3 tags.
For a complete list of standard ID3 tags, visit http://id3lib.sourceforge.net/id3/id3v2.3.0.html#sec4
Follow this function with Media_GetLastError to check for any error responses.
See Media_SetMetadata for information on how to change the metadata tags.
Examples
To get the full metadata list of an external sound file named “Bop.mp3” and stored on the desktop:
Set Field [ MyTable::Metadata ;
Media_GetMetadata (
MyTable::SoundContainer
) ]
To get only the value of the “Genre” tag from an external sound file named “Allegro.mp3” in the current default folder:
Set Field [ MyTable::Metadata ;
Media_GetMetadata (
MyTable::SoundContainer ;
"Genre"
) ]
To store the full metadata list in a field and, in a separate field, store the “Name” value:
Set Field [ MyTable::Metadata List;
Media_GetMetadata (
".D/sounds/pavane.mp3"
) ]
Set Field [ MyTable::Metadata Name ;
Media_ExtractInfo (
MyTable::Metadata List ;
"Name"
) ]