Package | com.wadedwalker.nativeExtension.media |
Class | public final class MediaMetadataRetriever |
Inheritance | MediaMetadataRetriever ![]() |
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The MediaMetadataRetriever
class is a Native Extension built for the purpose of
getting metadata from audio and video files. Currently in Flash, you can only get metadata after the
audio/video file has started to play and, in video playback for example, you listen for the
onMetaData
event to retrieve information such as video width/height and the embedded
image art.
For getting track information, use the extractMetadata
method combined with the
METADATA_KEY_XXXX
constants for the type of data you want to retrieve.
This can work for a multitude of file types including, but not necessarily limited to: MP3, M4A, M4B, MP4.
NOTE: For Android, all metadata types require API Level 10 (Android 2.3.3 Gingerbread MR1) at minimum unless otherwise stated.
NOTE: Depending on the Android device, the app may temporarily pause while the data is being retrieved and the app will visually appear unresponsive. This seems to only occur on Nexus devices (Galaxy Nexus, Nexus 4, and Nexus 5 tested). It also seems to only happen on M4A and M4B files that are large in file size (greater than 50MB) although this could be based on the device running the app. MP3 files appear to be ok, even on Nexus devices.
Property | Defined By | ||
---|---|---|---|
![]() [static] [read-only]
Deterimines whether or not this native extension is supported on the device the app is running on. | MediaMetadataRetriever |
Method | Defined By | ||
---|---|---|---|
MediaMetadataRetriever | |||
![]()
Properly shut down this Native Extension. | MediaMetadataRetriever | ||
![]()
Retrieves all available metadata. | MediaMetadataRetriever | ||
![]()
Retrieves the meta data value associated with the key code. | MediaMetadataRetriever | ||
![]()
Attempts to get the embedded picture in the source file provided. | MediaMetadataRetriever |
Constant | Defined By | ||
---|---|---|---|
![]() [static]
The metadata key to retrieve the information about the album title of the data source. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the information about the performers or artist associated with the
data source. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the information about the artist of the data source. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the information about the author of the data source. | MediaMetadataRetriever | ||
![]() [static]
This key retrieves the average bitrate (in bits/sec), if available. | MediaMetadataRetriever | ||
![]() [static]
This key retrieves the original capture framerate, if it's available. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the numeric string describing the order of the audio data source on
its original recording. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the music album compilation status. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the information about the composer of the data source. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the date when the data source was created or modified. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the numberic string that describes which part of a set the audio
data source comes from. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the playback duration of the data source. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the content type or genre of the data source. | MediaMetadataRetriever | ||
![]() [static]
If this key exists the media contains audio content. | MediaMetadataRetriever | ||
![]() [static]
If this key exists the media contains video content. | MediaMetadataRetriever | ||
![]() [static]
This key retrieves the location information, if available. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the mime type of the data source. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the number of tracks, such as audio, video, text, in the data
source, such as a mp4 or 3gpp file. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the data source title. | MediaMetadataRetriever | ||
![]() [static]
If the media contains video, this key retrieves its height. | MediaMetadataRetriever | ||
![]() [static]
This key retrieves the video rotation angle in degrees, if available. | MediaMetadataRetriever | ||
![]() [static]
If the media contains video, this key retrieves its width. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the information of the writer (such as lyricist) of the data
source. | MediaMetadataRetriever | ||
![]() [static]
The metadata key to retrieve the year when the data source was created or modified. | MediaMetadataRetriever |
![]() | property |
isSupported:Boolean
[read-only] Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Deterimines whether or not this native extension is supported on the device the app is running on.
public static function get isSupported():Boolean
MediaMetadataRetriever | () | Constructor |
public function MediaMetadataRetriever()
![]() | () | method |
public final function dispose():void
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Properly shut down this Native Extension.
![]() | () | method |
public final function extractAllMetadata(source:String):Vector.<String>
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Retrieves all available metadata. Depending on the file, there could be a lot of data available or there could be very little.
Parameters
source:String — The File.nativePath property of the media file you want to get the
metadata for.
|
Vector.<String> — Vector array containing the all available metadata information.
Values will be presented as "KEY = value".
|
![]() | () | method |
public final function extractMetadata(source:String, type:int):String
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Retrieves the meta data value associated with the key code. If the desired metadata cannot be
retrieved, it will return as an empty String. Use METADATA_KEY_XXXX
constants for the
type of data you want to retrieve.
Parameters
source:String — The File.nativePath property of the media file you want to get the
metadata for.
| |
type:int — The type of metadata to retrieve from the media source provided.
|
String — String containing the metadata information requested if it can be found.
Returns null if there was an error trying to get the information.
|
![]() | () | method |
public final function getEmbeddedPicture(source:String):ByteArray
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
Attempts to get the embedded picture in the source file provided. The source file can
be a audio or video file. If the embedded picture data can be found, it is returned as a
ByteArray
. From there, use the Loader
display object to "load" the image
using its loadBytes()
method to load the image.
Depending on the device and file, the ByteArray
may still be returned as non-null
even if the embedded picture data cannot be found. Checking the ByteArray.length
property would be a good way to check if there is actually any data. In testing, a value check of
greater than 100 worked to see if there is truly data available.
Parameters
source:String — The File.nativePath property of the media file you want to get the
embedded picture data for. Passing in the File.url property will most likely
not work.
|
ByteArray — ByteArray containing the BitmapData of the embedded picture
data. Returns null if there was an error trying to get the embedded picture. If there
are more than one pictures, (any) one of them is returned.
|
![]() | Constant |
public static const METADATA_KEY_ALBUM:int = 0x00000001
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the information about the album title of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_ALBUMARTIST:int = 0x0000000d
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the information about the performers or artist associated with the data source.
See also
![]() | Constant |
public static const METADATA_KEY_ARTIST:int = 0x00000002
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the information about the artist of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_AUTHOR:int = 0x00000003
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the information about the author of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_BITRATE:int = 0x00000014
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
This key retrieves the average bitrate (in bits/sec), if available.
NOTE: Requires API Level 14 (Android 4.0 Ice Cream Sandwich) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_CAPTURE_FRAMERATE:int = 0x00000019
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
This key retrieves the original capture framerate, if it's available.
The capture framerate will be a floating point number as a String
.
NOTE: Requires API Level 23 (Android 6.0 Marshmallow) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_CD_TRACK_NUMBER:int = 0x00000000
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the numeric string describing the order of the audio data source on its original recording.
See also
![]() | Constant |
public static const METADATA_KEY_COMPILATION:int = 0x0000000f
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the music album compilation status.
See also
![]() | Constant |
public static const METADATA_KEY_COMPOSER:int = 0x00000004
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the information about the composer of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_DATE:int = 0x00000005
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the date when the data source was created or modified.
See also
![]() | Constant |
public static const METADATA_KEY_DISC_NUMBER:int = 0x0000000e
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the numberic string that describes which part of a set the audio data source comes from.
See also
![]() | Constant |
public static const METADATA_KEY_DURATION:int = 0x00000009
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the playback duration of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_GENRE:int = 0x00000006
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the content type or genre of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_HAS_AUDIO:int = 0x00000010
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
If this key exists the media contains audio content.
NOTE: Requires API Level 14 (Android 4.0 Ice Cream Sandwich) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_HAS_VIDEO:int = 0x00000011
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
If this key exists the media contains video content.
NOTE: Requires API Level 14 (Android 4.0 Ice Cream Sandwich) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_LOCATION:int = 0x00000017
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
This key retrieves the location information, if available.
NOTE: Requires API Level 15 (Android 4.0.3 Ice Cream Sandwich MR1) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_MIMETYPE:int = 0x0000000c
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the mime type of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_NUM_TRACKS:int = 0x0000000a
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the number of tracks, such as audio, video, text, in the data source, such as a mp4 or 3gpp file.
See also
![]() | Constant |
public static const METADATA_KEY_TITLE:int = 0x00000007
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the data source title.
See also
![]() | Constant |
public static const METADATA_KEY_VIDEO_HEIGHT:int = 0x00000013
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
If the media contains video, this key retrieves its height.
NOTE: Requires API Level 14 (Android 4.0 Ice Cream Sandwich) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_VIDEO_ROTATION:int = 0x00000018
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
This key retrieves the video rotation angle in degrees, if available.
NOTE: Requires API Level 17 (Android 4.2 Jelly Bean MR1) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_VIDEO_WIDTH:int = 0x00000012
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
If the media contains video, this key retrieves its width.
NOTE: Requires API Level 14 (Android 4.0 Ice Cream Sandwich) or higher.
See also
![]() | Constant |
public static const METADATA_KEY_WRITER:int = 0x0000000b
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the information of the writer (such as lyricist) of the data source.
See also
![]() | Constant |
public static const METADATA_KEY_YEAR:int = 0x00000008
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 2.5 |
The metadata key to retrieve the year when the data source was created or modified.
See also
package { import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import com.wadedwalker.nativeExtension.media.MediaMetadataRetriever; final public class MyAndroidApp extends Sprite { private var _mmr:MediaMetadataRetriever; prviate var _loader:Loader; final public function MyAndroidApp() { _mmr = new MediaMetadataRetriever(); _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onCoverArtLoaded); // load the ByteArray of the cover art image // if there is more than 1 cover art asset in this media file, the first one will be loaded _loader.loadBytes(_mmr.getEmbeddedPicture(mediaFile.nativePath)); } final private function _onCoverArtLoaded(e:Event):void { _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, _onCoverArtLoaded); this.addChild(_loader.content); } } }
package { import flash.display.Sprite; import flash.text.TextField; import com.wadedwalker.nativeExtension.media.MediaMetadataRetriever; final public class MyAndroidApp extends Sprite { private var _mmr:MediaMetadataRetriever; prviate var _songInfo:TextField; final public function MyAndroidApp() { _songInfo = new TextField(); this.addChild(_songInfo); _mmr = new MediaMetadataRetriever(); _songInfo.appendText("Title: " + _mmr.extractMetadata(mediaFile.nativePath, MediaMetadataRetriever.METADATA_KEY_TITLE) + "\n"); _songInfo.appendText("Album: " + _mmr.extractMetadata(mediaFile.nativePath, MediaMetadataRetriever.METADATA_KEY_ALBUM) + "\n"); _songInfo.appendText("Artist: " + _mmr.extractMetadata(mediaFile.nativePath, MediaMetadataRetriever.METADATA_KEY_ARTIST) + "\n"); _songInfo.appendText("Track #" + _mmr.extractMetadata(mediaFile.nativePath, MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER) + "\n"); } } }