public abstract class MediaMetadataEditor
extends Object
| java.lang.Object | |
| ↳ | android.media.MediaMetadataEditor |
| |
该类在API级别21中已被弃用。
用MediaMetadata代替MediaSession 。
用于编辑和存储可由RemoteControlClient发布的元数据的抽象类。 请参阅editMetadata(boolean)方法来实例化RemoteControlClient.MetadataEditor对象。
Constants |
|
|---|---|
int |
BITMAP_KEY_ARTWORK 内容艺术作品/专辑封面的元数据关键字。 |
int |
RATING_KEY_BY_OTHERS 内容平均评分的元数据键,而不是用户的评分。 |
int |
RATING_KEY_BY_USER 内容用户评分的元数据关键字。 |
Public methods |
|
|---|---|
void |
addEditableKey(int key) 将给定的键标记为可编辑的。 |
abstract void |
apply() 应用自MediaMetadataEditor实例创建以来或自 |
void |
clear() 清除自MediaMetadataEditor实例创建或自上次调用此方法以来设置的所有待定元数据更改。 |
Bitmap |
getBitmap(int key, Bitmap defaultValue) 返回密钥的 |
int[] |
getEditableKeys() 检索标记为可编辑的键。 |
long |
getLong(int key, long defaultValue) 返回键的长整型值。 |
Object |
getObject(int key, Object defaultValue) 返回键的值的对象表示形式 |
String |
getString(int key, String defaultValue) 返回密钥的 |
MediaMetadataEditor |
putBitmap(int key, Bitmap bitmap) 添加图像。 |
MediaMetadataEditor |
putLong(int key, long value) 添加数字信息。 |
MediaMetadataEditor |
putObject(int key, Object value) 添加存储为实例的信息。 |
MediaMetadataEditor |
putString(int key, String value) 添加文字信息。 |
void |
removeEditableKeys() 导致所有元数据字段为只读。 |
Inherited methods |
|
|---|---|
java.lang.Object
|
|
int BITMAP_KEY_ARTWORK
内容艺术作品/专辑封面的元数据关键字。
常量值:100(0x00000064)
int RATING_KEY_BY_OTHERS
内容平均评分的元数据键,而不是用户的评分。 与此密钥关联的值是Rating实例。
也可以看看:
常量值:101(0x00000065)
int RATING_KEY_BY_USER
内容用户评分的元数据关键字。 与此密钥关联的值是Rating实例。 此密钥可以标记为“可编辑”( addEditableKey(int) ),以通过RemoteControlClient.OnMetadataUpdateListener接口启用接收用户评级值。
常量值:268435457(0x10000001)
void addEditableKey (int key)
将给定的键标记为可编辑的。 这应该仅由元数据发布者使用,例如RemoteControlClient ,它将声明元数据字段有资格进行更新,并通过RemoteControlClient.OnMetadataUpdateListener接口接收新值。
| Parameters | |
|---|---|
key |
int: the type of metadata that can be edited. The supported key is RATING_KEY_BY_USER. |
void apply ()
应用自MediaMetadataEditor实例创建以来或自clear()被调用以来所设置的所有元数据更改。 为了线程安全,子类应该在this同步。
void clear ()
清除自MediaMetadataEditor实例创建或自上次调用此方法以来设置的所有待定元数据更改。 请注意,清除元数据不会重置可编辑键(改为使用removeEditableKeys() )。
Bitmap getBitmap (int key, Bitmap defaultValue)
返回密钥的 Bitmap值。
| 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 | |
|---|---|
IllegalArgumentException |
|
int[] getEditableKeys ()
检索标记为可编辑的键。
| Returns | |
|---|---|
int[] |
null if there are no editable keys, or an array containing the keys. |
long getLong (int key,
long defaultValue)
返回键的长整型值。
| 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 | |
|---|---|
IllegalArgumentException |
|
Object getObject (int key, Object defaultValue)
返回键的值的对象表示形式
| Parameters | |
|---|---|
key |
int: one of the keys supported in putObject(int, 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 | |
|---|---|
IllegalArgumentException |
|
String getString (int key, String defaultValue)
返回密钥的 String值。
| Parameters | |
|---|---|
key |
int: one of the keys supported in putString(int, 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 | |
|---|---|
IllegalArgumentException |
|
MediaMetadataEditor putBitmap (int key, Bitmap bitmap)
添加图像。
| 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 | |
|---|---|
|
IllegalArgumentException |
IllegalArgumentException |
|
也可以看看:
MediaMetadataEditor putLong (int key, long value)
添加数字信息。 请注意,调用apply()后添加的所有信息都不会被MediaMetadataEditor存储的元数据的消费者使用。
| Parameters | |
|---|---|
key |
int: the identifier of a the metadata field to set. Valid values are METADATA_KEY_CD_TRACK_NUMBER, METADATA_KEY_DISC_NUMBER, METADATA_KEY_DURATION (with a value expressed in milliseconds), 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 | |
|---|---|
IllegalArgumentException |
|
MediaMetadataEditor putObject (int key, Object value)
添加存储为实例的信息。 请注意,调用apply()后添加的所有信息都不会被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 | |
|---|---|
IllegalArgumentException |
|
MediaMetadataEditor putString (int key, String value)
添加文字信息。 请注意,在调用apply()之后添加的所有信息都不会被MediaMetadataEditor存储的元数据消费者使用。
| Parameters | |
|---|---|
key |
int: The identifier of a the metadata field to set. Valid values are METADATA_KEY_ALBUM, METADATA_KEY_ALBUMARTIST, METADATA_KEY_TITLE, METADATA_KEY_ARTIST, METADATA_KEY_AUTHOR, METADATA_KEY_COMPILATION, METADATA_KEY_COMPOSER, METADATA_KEY_DATE, METADATA_KEY_GENRE, 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 |
|