Build 1.0_r1(from source)

android.media
Class MediaMetadataRetriever

java.lang.Object
  extended by android.media.MediaMetadataRetriever

public class MediaMetadataRetriever
extends Object

MediaMetadataRetriever class provides a unified interface for retrieving frame and meta data from an input media file.


Field Summary
static int METADATA_KEY_ALBUM
           
static int METADATA_KEY_ARTIST
           
static int METADATA_KEY_AUTHOR
           
static int METADATA_KEY_CD_TRACK_NUMBER
           
static int METADATA_KEY_COMPOSER
           
static int METADATA_KEY_DATE
           
static int METADATA_KEY_DURATION
           
static int METADATA_KEY_GENRE
           
static int METADATA_KEY_NUM_TRACKS
           
static int METADATA_KEY_TITLE
           
static int METADATA_KEY_YEAR
           
static int MODE_CAPTURE_FRAME_ONLY
           
static int MODE_GET_METADATA_ONLY
           
 
Constructor Summary
MediaMetadataRetriever()
           
 
Method Summary
 Bitmap captureFrame()
          Call this method after setDataSource().
 byte[] extractAlbumArt()
          Call this method after setDataSource().
 String extractMetadata(int keyCode)
          Call this method after setDataSource().
protected  void finalize()
          Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
 void release()
          Call it when one is done with the object.
 void setDataSource(String path)
          Call this method before the rest.
 void setMode(int mode)
          Call this method before setDataSource() so that the mode becomes effective for subsequent operations.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_GET_METADATA_ONLY

public static final int MODE_GET_METADATA_ONLY
See Also:
Constant Field Values

MODE_CAPTURE_FRAME_ONLY

public static final int MODE_CAPTURE_FRAME_ONLY
See Also:
Constant Field Values

METADATA_KEY_CD_TRACK_NUMBER

public static final int METADATA_KEY_CD_TRACK_NUMBER
See Also:
Constant Field Values

METADATA_KEY_ALBUM

public static final int METADATA_KEY_ALBUM
See Also:
Constant Field Values

METADATA_KEY_ARTIST

public static final int METADATA_KEY_ARTIST
See Also:
Constant Field Values

METADATA_KEY_AUTHOR

public static final int METADATA_KEY_AUTHOR
See Also:
Constant Field Values

METADATA_KEY_COMPOSER

public static final int METADATA_KEY_COMPOSER
See Also:
Constant Field Values

METADATA_KEY_DATE

public static final int METADATA_KEY_DATE
See Also:
Constant Field Values

METADATA_KEY_GENRE

public static final int METADATA_KEY_GENRE
See Also:
Constant Field Values

METADATA_KEY_TITLE

public static final int METADATA_KEY_TITLE
See Also:
Constant Field Values

METADATA_KEY_YEAR

public static final int METADATA_KEY_YEAR
See Also:
Constant Field Values

METADATA_KEY_DURATION

public static final int METADATA_KEY_DURATION
See Also:
Constant Field Values

METADATA_KEY_NUM_TRACKS

public static final int METADATA_KEY_NUM_TRACKS
See Also:
Constant Field Values
Constructor Detail

MediaMetadataRetriever

public MediaMetadataRetriever()
Method Detail

setMode

public void setMode(int mode)
Call this method before setDataSource() so that the mode becomes effective for subsequent operations. This method can be called only once at the beginning if the intended mode of operation for a MediaMetadataRetriever object remains the same for its whole lifetime, and thus it is unnecessary to call this method each time setDataSource() is called. If this is not never called (which is allowed), by default the intended mode of operation is to both capture frame and retrieve meta data (i.e., MODE_GET_METADATA_ONLY | MODE_CAPTURE_FRAME_ONLY). Often, this may not be what one wants, since doing this has negative performance impact on execution time of a call to setDataSource(), since both types of operations may be time consuming.

Parameters:
mode - The intended mode of operation. Can be any combination of MODE_GET_METADATA_ONLY and MODE_CAPTURE_FRAME_ONLY: 1. MODE_GET_METADATA_ONLY & MODE_CAPTURE_FRAME_ONLY: For neither frame capture nor meta data retrieval 2. MODE_GET_METADATA_ONLY: For meta data retrieval only 3. MODE_CAPTURE_FRAME_ONLY: For frame capture only 4. MODE_GET_METADATA_ONLY | MODE_CAPTURE_FRAME_ONLY: For both frame capture and meta data retrieval

setDataSource

public void setDataSource(String path)
                   throws IllegalArgumentException
Call this method before the rest. This method may be time-consuming.

Parameters:
path - The path of the input media file.
Throws:
IllegalArgumentException - If the path is invalid.

extractMetadata

public String extractMetadata(int keyCode)
Call this method after setDataSource(). This method retrieves the meta data value associated with the keyCode. The keyCode currently supported is listed below as METADATA_XXX constants. With any other value, it returns a null pointer.

Parameters:
keyCode - One of the constants listed below at the end of the class.
Returns:
The meta data value associate with the given keyCode on success; null on failure.

captureFrame

public Bitmap captureFrame()
Call this method after setDataSource(). This method finds a representative frame if successful and returns it as a bitmap. This is useful for generating a thumbnail for an input media source.

Returns:
A Bitmap containing a representative video frame, which can be null, if such a frame cannot be retrieved.

extractAlbumArt

public byte[] extractAlbumArt()
Call this method after setDataSource(). This method finds the optional graphic or album art associated (embedded or external url linked) the related data source.

Returns:
null if no such graphic is found.

release

public void release()
Call it when one is done with the object. This method releases the memory allocated internally.


finalize

protected void finalize()
                 throws Throwable
Description copied from class: Object
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.

Note: The virtual machine assumes that the implementation in class Object is empty.

Overrides:
finalize in class Object
Throws:
Throwable - The virtual machine ignores any exceptions which are thrown during finalization.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature