Media_GetMetadata ( containerOrFile { ; frameNameOrAtCode { ; 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 or metadata in an AAC file. You can either view the entire list of ID3 frames, or a specific frame, like “Artist,” etc.
Parameter | Description |
---|---|
containerOrFile |
Location of the sound file. The container parameter can be:
|
frameNameOrAtCode | Optional parameter. Optional parameter. If you want to view only a specific piece of information. Frames can be referred to by name or by code (see below). The following names are supported for MP3:
|
getTagsAsCodes | Optional parameter.
|
List all Metadata Values
Set Field [ MyTable::Metadata ;
Media_GetMetadata ( containerOrFile ) ]
When the optional “frameNameOrAtCode” 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 frame, request that frame directly from the function, or use the Media_ExtractInfo function for the text format or code format. You can also parse the value from the JSON format by using FileMaker’s capabilities or by using Media_JSONPath.
Returning a Single Frame Value
If you don’t want the entire metadata list and you know the name of a particular value you want, you can specify frame 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 ;
"" ; # empty = all frames
1 # 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 Frame Value using frame code
Set Field [ MyTable::Metadata ;
Media_GetMetadata (
containerOrFile ;
"@TYER" ; # TYER ID3 Frame
1 # use @codes
) ]
For a sound file with the metadata shown above, MediaManager will respond with “1995”.
To use ID3 frames 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 frames currently in use within a file’s metadata, follow the instructions above to list all metadata values using ID3 frame codes.
For a complete list of standard ID3 frames, 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"
) ]