本文整理汇总了Java中android.media.RemoteControlClient.MetadataEditor.apply方法的典型用法代码示例。如果您正苦于以下问题:Java MetadataEditor.apply方法的具体用法?Java MetadataEditor.apply怎么用?Java MetadataEditor.apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.RemoteControlClient.MetadataEditor
的用法示例。
在下文中一共展示了MetadataEditor.apply方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateRemoteControlClientMetadata
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
if (!LibVlcUtil.isICSOrLater()) // NOP check
return;
Media media = getCurrentMedia();
if (mRemoteControlClient != null && media != null) {
MetadataEditor editor = mRemoteControlClient.editMetadata(true);
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, media.getAlbum());
editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, media.getArtist());
editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, media.getGenre());
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle());
editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength());
// Copy the cover bitmap because the RemonteControlClient can recycle its artwork bitmap.
Bitmap cover = getCover();
editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, ((cover != null) ? cover.copy(cover.getConfig(), false) : null));
editor.apply();
}
}
示例2: updateRemoteControlClientMetadata
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
if(!Util.isICSOrLater()) // NOP check
return;
Media media = getCurrentMedia();
if (mRemoteControlClient != null && media != null) {
MetadataEditor editor = mRemoteControlClient.editMetadata(true);
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, media.getAlbum());
editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, media.getArtist());
editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, media.getGenre());
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle());
editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength());
editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, getCover());
editor.apply();
}
}
示例3: showNotify
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
public void showNotify(String artist, String album, String title, int tracknr) {
getAudioFocus();
mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
MetadataEditor edit = mRemoteControlClient.editMetadata(true);
edit.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title);
edit.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist);
edit.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, artist);
edit.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, album);
edit.putLong(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, tracknr);
edit.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, 10);
edit.apply();
int timeout = getTimeout();
if (timeout != 0) {
mHandler.removeMessages(HANDLER_WHAT_CLEAR);
mHandler.sendEmptyMessageDelayed(HANDLER_WHAT_CLEAR, timeout * 1000);
}
}
示例4: setMetadata
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
public static void setMetadata(Object rccObj, Bundle metadata, long actions) {
MetadataEditor editor = ((RemoteControlClient) rccObj).editMetadata(true);
MediaSessionCompatApi14.buildOldMetadata(metadata, editor);
addNewMetadata(metadata, editor);
if ((128 & actions) != 0) {
editor.addEditableKey(268435457);
}
editor.apply();
}
示例5: updateRemoteControlClientMetadata
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
if (!AndroidUtil.isICSOrLater()) // NOP check
return;
MediaWrapper media = getCurrentMedia();
if (mRemoteControlClient != null && media != null) {
MetadataEditor editor = mRemoteControlClient.editMetadata(true);
if (media.getNowPlaying() != null) {
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, "");
editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, "");
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, media.getNowPlaying());
} else {
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, "");
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, Util.getMediaAlbum(this, media));
editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, Util.getMediaArtist(this, media));
}
editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, Util.getMediaGenre(this, media));
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, media.getTitle());
editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, media.getLength());
// Copy the cover bitmap because the RemonteControlClient can recycle its artwork bitmap.
Bitmap cover = AudioUtil.getCover(this, media, 512);
if (cover != null && cover.getConfig() != null) //In case of format not supported
editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, (cover.copy(cover.getConfig(), false)));
editor.apply();
}
//Send metadata to Pebble watch
if (media != null && mPebbleEnabled) {
final Intent i = new Intent("com.getpebble.action.NOW_PLAYING");
i.putExtra("artist", Util.getMediaArtist(this, media));
i.putExtra("album", Util.getMediaAlbum(this, media));
i.putExtra("track", media.getTitle());
sendBroadcast(i);
}
}
示例6: setMusicInfo
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
@TargetApi(14)
private void setMusicInfo(Music song) {
if (Build.VERSION.SDK_INT > 14 && remoteControlClient != null && song != null) {
MetadataEditor editor = ((RemoteControlClient) remoteControlClient).editMetadata(true);
//TODO : maybe add cover art here someday
editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, song.getTime() * 1000);
editor.putLong(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, song.getTrack());
editor.putLong(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER, song.getDisc());
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, song.getAlbum());
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, song.getAlbumArtist());
editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, song.getArtist());
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, song.getTitle());
editor.apply();
}
}
示例7: setMetadata
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
public static void setMetadata(Object rccObj, Bundle metadata) {
MetadataEditor editor = ((RemoteControlClient) rccObj).editMetadata(true);
buildOldMetadata(metadata, editor);
editor.apply();
}
示例8: notifyChange
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
/**
* Notify the change-receivers that something has changed. The intent that
* is sent contains the following data for the currently playing track: "id"
* - Integer: the database row ID "artist" - String: the name of the artist
* "album" - String: the name of the album "track" - String: the name of the
* track The intent has an action that is one of
* "com.andrew.apolloMod.metachanged" "com.andrew.apolloMod.queuechanged",
* "com.andrew.apolloMod.playbackcomplete" "com.andrew.apolloMod.playstatechanged"
* respectively indicating that a new track has started playing, that the
* playback queue has changed, that playback has stopped because the last
* file in the list has been played, or that the play-state changed
* (paused/resumed).
*/
public void notifyChange(String what) {
Intent i = new Intent(what);
i.putExtra("id", Long.valueOf(getAudioId()));
i.putExtra("artist", getArtistName());
i.putExtra("album", getAlbumName());
i.putExtra("track", getTrackName());
i.putExtra("playing", mIsSupposedToBePlaying);
i.putExtra("isfavorite", isFavorite());
sendStickyBroadcast(i);
i = new Intent(i);
i.setAction(what.replace(APOLLO_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
sendStickyBroadcast(i);
if (what.equals(PLAYSTATE_CHANGED)) {
mRemoteControlClient
.setPlaybackState(mIsSupposedToBePlaying ? RemoteControlClient.PLAYSTATE_PLAYING
: RemoteControlClient.PLAYSTATE_PAUSED);
} else if (what.equals(META_CHANGED)) {
MetadataEditor ed = mRemoteControlClient.editMetadata(true);
ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
Bitmap b = getAlbumBitmap();
if (b != null) {
ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b);
}
ed.apply();
}
if (what.equals(QUEUE_CHANGED)) {
saveQueue(true);
} else {
saveQueue(false);
}
mAppWidgetProvider1x1.notifyChange(this, what);
mAppWidgetProvider4x1.notifyChange(this, what);
mAppWidgetProvider4x2.notifyChange(this, what);
}
示例9: refreshRemoteControlClientState
import android.media.RemoteControlClient.MetadataEditor; //导入方法依赖的package包/类
/**
* Refresh player status and metadata.
*/
@SuppressLint("NewApi")
private void refreshRemoteControlClientState(PlaybackServiceMediaPlayer.PSMPInfo info) {
if (android.os.Build.VERSION.SDK_INT >= 14) {
if (remoteControlClient != null) {
switch (info.playerStatus) {
case PLAYING:
remoteControlClient
.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
break;
case PAUSED:
case INITIALIZED:
remoteControlClient
.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
break;
case STOPPED:
remoteControlClient
.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
break;
case ERROR:
remoteControlClient
.setPlaybackState(RemoteControlClient.PLAYSTATE_ERROR);
break;
default:
remoteControlClient
.setPlaybackState(RemoteControlClient.PLAYSTATE_BUFFERING);
}
if (info.playable != null) {
MetadataEditor editor = remoteControlClient
.editMetadata(false);
editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE,
info.playable.getEpisodeTitle());
editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM,
info.playable.getFeedTitle());
editor.apply();
}
if (AppConfig.DEBUG)
Log.d(TAG, "RemoteControlClient state was refreshed");
}
}
}