Added in API level 19
Deprecated in API level 21

MediaMetadataEditor


public abstract class MediaMetadataEditor
extends Object

java.lang.Object
   ↳ android.media.MediaMetadataEditor


This class was deprecated in API level 21.
Use MediaMetadata instead together with MediaSession.

An abstract class for editing and storing metadata that can be published by RemoteControlClient. See the RemoteControlClient.editMetadata(boolean) method to instantiate a RemoteControlClient.MetadataEditor object.

Summary

Constants

int BITMAP_KEY_ARTWORK

The metadata key for the content artwork / album art.

int RATING_KEY_BY_OTHERS

The metadata key for the content's average rating, not the user's rating.

int RATING_KEY_BY_USER

The metadata key for the content's user rating.

Public methods

void addEditableKey(int key)

Flags the given key as being editable.

abstract void apply()

Applies all of the metadata changes that have been set since the MediaMetadataEditor instance was created or since clear() was called.

void clear()

Clears all the pending metadata changes set since the MediaMetadataEditor instance was created or since this method was last called.

Bitmap getBitmap(int key, Bitmap defaultValue)

Returns the Bitmap value for the key.

int[] getEditableKeys()

Retrieves the keys flagged as editable.

long getLong(int key, long defaultValue)

Returns the long value for the key.

Object getObject(int key, Object defaultValue)

Returns an object representation of the value for the key

String getString(int key, String defaultValue)

Returns the String value for the key.

MediaMetadataEditor putBitmap(int key, Bitmap bitmap)

Adds image.

MediaMetadataEditor putLong(int key, long value)

Adds numerical information.

MediaMetadataEditor putObject(int key, Object value)

Adds information stored as an instance.

MediaMetadataEditor putString(int key, String value)

Adds textual information.

void removeEditableKeys()

Causes all metadata fields to be read-only.

Inherited methods

Constants

BITMAP_KEY_ARTWORK

Added in API level 19
public static final int BITMAP_KEY_ARTWORK

The metadata key for the content artwork / album art.

Constant Value: 100 (0x00000064)

RATING_KEY_BY_OTHERS

Added in API level 19
public static final int RATING_KEY_BY_OTHERS

The metadata key for the content's average rating, not the user's rating. The value associated with this key is a Rating instance.

See also:

Constant Value: 101 (0x00000065)

RATING_KEY_BY_USER

Added in API level 19
public static final int RATING_KEY_BY_USER

The metadata key for the content's user rating. The value associated with this key is a Rating instance. This key can be flagged as "editable" (with addEditableKey(int)) to enable receiving user rating values through the RemoteControlClient.OnMetadataUpdateListener interface.

Constant Value: 268435457 (0x10000001)

Public methods

addEditableKey

Added in API level 19
public void addEditableKey (int key)

Flags the given key as being editable. This should only be used by metadata publishers, such as RemoteControlClient, which will declare the metadata field as eligible to be updated, with new values received through the RemoteControlClient.OnMetadataUpdateListener interface.

Parameters
key int: the type of metadata that can be edited. The supported key is RATING_KEY_BY_USER.

apply

Added in API level 19
public abstract void apply ()

Applies all of the metadata changes that have been set since the MediaMetadataEditor instance was created or since clear() was called. Subclasses should synchronize on this for thread safety.

clear

Added in API level 19
public void clear ()

Clears all the pending metadata changes set since the MediaMetadataEditor instance was created or since this method was last called. Note that clearing the metadata doesn't reset the editable keys (use removeEditableKeys() instead).

getBitmap

Added in API level 19
public Bitmap getBitmap (int key, 
                Bitmap defaultValue)

Returns the Bitmap value for the key.

Parameters
key int: the BITMAP_KEY_ARTWORK key

defaultValue Bitmap: the value returned if the key is not present

Returns
Bitmap the Bitmap value for the key, or the supplied default value if the key is not present

Throws
java.lang.IllegalArgumentException
IllegalArgumentException

getEditableKeys

Added in API level 19
public int[] getEditableKeys ()

Retrieves the keys flagged as editable.

Returns
int[] null if there are no editable keys, or an array containing the keys.

getLong

Added in API level 19
public long getLong (int key, 
                long defaultValue)

Returns the long value for the key.

Parameters
key int: one of the keys supported in putLong(int, long)

defaultValue long: the value returned if the key is not present

Returns
long the long value for the key, or the supplied default value if the key is not present

Throws
java.lang.IllegalArgumentException
IllegalArgumentException

getObject

Added in API level 19
public Object getObject (int key, 
                Object defaultValue)

Returns an object representation of the value for the key

Parameters
key int: one of the keys supported in putObject(int, java.lang.Object)

defaultValue Object: the value returned if the key is not present

Returns
Object the object for the key, as a Long, Bitmap, String, or Rating depending on the key value, or the supplied default value if the key is not present

Throws
java.lang.IllegalArgumentException
IllegalArgumentException

getString

Added in API level 19
public String getString (int key, 
                String defaultValue)

Returns the String value for the key.

Parameters
key int: one of the keys supported in putString(int, java.lang.String)

defaultValue String: the value returned if the key is not present

Returns
String the String value for the key, or the supplied default value if the key is not present

Throws
java.lang.IllegalArgumentException
IllegalArgumentException

putBitmap

Added in API level 19
public MediaMetadataEditor putBitmap (int key, 
                Bitmap bitmap)

Adds image.

Parameters
key int: the identifier of the bitmap to set. The only valid value is BITMAP_KEY_ARTWORK

bitmap Bitmap: The bitmap for the artwork, or null if there isn't any.

Returns
MediaMetadataEditor Returns a reference to the same MediaMetadataEditor object, so you can chain put calls together.

Throws
java.lang.IllegalArgumentException
IllegalArgumentException

See also:

putLong

Added in API level 19
public MediaMetadataEditor putLong (int key, 
                long value)

Adds numerical information. Note that none of the information added after apply() has been called will be available to consumers of metadata stored by the MediaMetadataEditor.

Parameters
key int: the identifier of a the metadata field to set. Valid values are MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER, MediaMetadataRetriever.METADATA_KEY_DURATION (with a value expressed in milliseconds), MediaMetadataRetriever.METADATA_KEY_YEAR.

value long: The long value for the given key

Returns
MediaMetadataEditor Returns a reference to the same MediaMetadataEditor object, so you can chain put calls together.

Throws
java.lang.IllegalArgumentException
IllegalArgumentException

putObject

Added in API level 19
public MediaMetadataEditor putObject (int key, 
                Object value)

Adds information stored as an instance. Note that none of the information added after apply() has been called will be available to consumers of metadata stored by the MediaMetadataEditor.

Parameters
key int: the identifier of a the metadata field to set. Valid keys for a:

value Object: the metadata to add.

Returns
MediaMetadataEditor Returns a reference to the same MediaMetadataEditor object, so you can chain put calls together.

Throws
java.lang.IllegalArgumentException
IllegalArgumentException

putString

Added in API level 19
public MediaMetadataEditor putString (int key, 
                String value)

Adds textual information. Note that none of the information added after apply() has been called, will be available to consumers of metadata stored by the MediaMetadataEditor.

Parameters
key int: The identifier of a the metadata field to set. Valid values are MediaMetadataRetriever.METADATA_KEY_ALBUM, MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, MediaMetadataRetriever.METADATA_KEY_TITLE, MediaMetadataRetriever.METADATA_KEY_ARTIST, MediaMetadataRetriever.METADATA_KEY_AUTHOR, MediaMetadataRetriever.METADATA_KEY_COMPILATION, MediaMetadataRetriever.METADATA_KEY_COMPOSER, MediaMetadataRetriever.METADATA_KEY_DATE, MediaMetadataRetriever.METADATA_KEY_GENRE, MediaMetadataRetriever.METADATA_KEY_WRITER.

value String: The text for the given key, or null to signify there is no valid information for the field.

Returns
MediaMetadataEditor Returns a reference to the same MediaMetadataEditor object, so you can chain put calls together.

Throws
IllegalArgumentException

removeEditableKeys

Added in API level 19
public void removeEditableKeys ()

Causes all metadata fields to be read-only.