android.media.RemoteControlClient.MetadataEditor Java Examples
The following examples show how to use
android.media.RemoteControlClient.MetadataEditor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AvrcpService.java From Botifier with BSD 2-Clause "Simplified" License | 6 votes |
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); } }
Example #2
Source File: ApolloService.java From mobile-manager-tool with MIT License | 4 votes |
/** * 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); }
Example #3
Source File: PlaybackService.java From AntennaPodSP with MIT License | 4 votes |
/** * 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"); } } }