List of usage examples for android.media RemoteControlClient editMetadata
public MetadataEditor editMetadata(boolean startEmpty)
From source file:github.madmarty.madsonic.util.ImageLoader.java
private void setImage(RemoteControlClient remoteControl, Drawable drawable) { if (remoteControl != null && drawable != null) { Bitmap origBitmap = ((BitmapDrawable) drawable).getBitmap(); remoteControl.editMetadata(false).putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, origBitmap.copy(origBitmap.getConfig(), true)).apply(); }/* w ww.j av a 2 s.c o m*/ }
From source file:github.daneren2005.dsub.util.ImageLoader.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setImage(RemoteControlClient remoteControl, Drawable drawable) { if (remoteControl != null && drawable != null) { Bitmap origBitmap = ((BitmapDrawable) drawable).getBitmap(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && origBitmap != null) { origBitmap = origBitmap.copy(origBitmap.getConfig(), false); }/*from ww w .java 2 s . c om*/ if (origBitmap != null && !origBitmap.isRecycled()) { remoteControl.editMetadata(false) .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, origBitmap).apply(); } else { if (origBitmap != null) { Log.e(TAG, "Tried to load a recycled bitmap."); } remoteControl.editMetadata(false) .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, null).apply(); } } }
From source file:com.twistedequations.rotor.MediaMetadataCompat.java
/** * Maps the values in the metadata to the equivalent fields in the {@link android.media.RemoteControlClient} * @param remoteControlClient the RemoteControlClient to populate * @return the populated RemoteControlClient *//*from www .j a v a2 s.co m*/ @TargetApi(Build.VERSION_CODES.KITKAT) public RemoteControlClient populateRemoteControlClient(RemoteControlClient remoteControlClient) { if (EDITOR_KEY_MAPPING == null) { //Lazy fill the mapping fillEditorKeyMapping(); } if (EDITOR_KEYS_TYPE == null) { //Lazy fill the mapping fillEditorTypeMapping(); } String compatKey; int editorKey; RemoteControlClient.MetadataEditor editor = remoteControlClient.editMetadata(true); for (int i = 0; i < EDITOR_KEY_MAPPING.size(); i++) { editorKey = EDITOR_KEY_MAPPING.keyAt(i); compatKey = EDITOR_KEY_MAPPING.get(editorKey); int type = METADATA_KEYS_TYPE.get(compatKey); Integer editorType = EDITOR_KEYS_TYPE.get(editorKey); switch (type) { case METADATA_TYPE_TEXT: String data = getString(compatKey); if (data != null && editorType != null && editorType == METADATA_TYPE_TEXT) { editor.putString(editorKey, data); } break; case METADATA_TYPE_BITMAP: Bitmap bitmap = getBitmap(compatKey); if (bitmap != null && editorType != null && editorType == METADATA_TYPE_BITMAP) { editor.putBitmap(editorKey, bitmap); } break; case METADATA_TYPE_LONG: long valueLong = getLong(compatKey); if (editorType != null && editorType == METADATA_TYPE_LONG) { editor.putLong(editorKey, valueLong); } break; case METADATA_TYPE_RATING: RatingCompat ratingCompat = getRating(compatKey); if (editorType != null && editorType == METADATA_TYPE_RATING) { editor.putObject(editorKey, ratingCompat.getRating()); } break; } } editor.apply(); return remoteControlClient; }
From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java
@TargetApi(19) private void setMetaData() { RemoteControlClient localRemoteControlClient = (RemoteControlClient) this.remoteControlClient; RemoteControlClient.MetadataEditor editor = localRemoteControlClient.editMetadata(true); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, authorField.getText().toString()); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, bookTitle); editor.apply();/* w w w . j a v a2 s. co m*/ //Set cover too? localRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); LOG.debug("Focus: updated meta-data"); }