List of usage examples for android.media MediaMetadataRetriever METADATA_KEY_ALBUMARTIST
int METADATA_KEY_ALBUMARTIST
To view the source code for android.media MediaMetadataRetriever METADATA_KEY_ALBUMARTIST.
Click Source Link
From source file:de.qspool.clementineremote.backend.ClementinePlayerConnection.java
/** * Update the RemoteControlClient/*from w w w. java2 s .c o m*/ */ private void updateRemoteControlClient() { // Update playstate if (App.mClementine.getState() == Clementine.State.PLAY) { mRcClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } else { mRcClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); } // Get the metadata editor if (mLastSong != null && mLastSong.getArt() != null) { RemoteControlClient.MetadataEditor editor = mRcClient.editMetadata(false); editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, mLastSong.getArt()); // The RemoteControlClients displays the following info: // METADATA_KEY_TITLE (white) - METADATA_KEY_ALBUMARTIST (grey) - METADATA_KEY_ALBUM (grey) // // So i put the metadata not in the "correct" fields to display artist, track and album // TODO: Fix it when changed in newer android versions editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, mLastSong.getAlbum()); editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, mLastSong.getArtist()); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, mLastSong.getTitle()); editor.apply(); } }
From source file:com.twistedequations.rotor.MediaMetadataCompat.java
@TargetApi(Build.VERSION_CODES.KITKAT) private static void fillEditorKeyMapping() { EDITOR_KEY_MAPPING = new SparseArray<String>(); EDITOR_KEY_MAPPING.put(MediaMetadataEditor.BITMAP_KEY_ARTWORK, METADATA_KEY_ART); EDITOR_KEY_MAPPING.put(MediaMetadataEditor.RATING_KEY_BY_OTHERS, METADATA_KEY_RATING); EDITOR_KEY_MAPPING.put(MediaMetadataEditor.RATING_KEY_BY_USER, METADATA_KEY_USER_RATING); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_ALBUM, METADATA_KEY_ALBUM); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, METADATA_KEY_ALBUM_ARTIST); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_ARTIST, METADATA_KEY_ARTIST); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_AUTHOR, METADATA_KEY_AUTHOR); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, METADATA_KEY_TRACK_NUMBER); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_COMPOSER, METADATA_KEY_COMPOSER); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_COMPILATION, METADATA_KEY_COMPILATION); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_DATE, METADATA_KEY_DATE); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER, METADATA_KEY_DISC_NUMBER); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_DURATION, METADATA_KEY_DURATION); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_GENRE, METADATA_KEY_GENRE); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_NUM_TRACKS, METADATA_KEY_NUM_TRACKS); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_TITLE, METADATA_KEY_TITLE); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_WRITER, METADATA_KEY_WRITER); EDITOR_KEY_MAPPING.put(MediaMetadataRetriever.METADATA_KEY_YEAR, METADATA_KEY_YEAR); }
From source file:com.twistedequations.rotor.MediaMetadataCompat.java
@TargetApi(Build.VERSION_CODES.KITKAT) private static void fillEditorTypeMapping() { EDITOR_KEYS_TYPE = new SparseArray<Integer>(26); EDITOR_KEYS_TYPE.put(MediaMetadataEditor.BITMAP_KEY_ARTWORK, METADATA_TYPE_BITMAP); EDITOR_KEYS_TYPE.put(MediaMetadataEditor.RATING_KEY_BY_OTHERS, METADATA_TYPE_RATING); EDITOR_KEYS_TYPE.put(MediaMetadataEditor.RATING_KEY_BY_USER, METADATA_TYPE_RATING); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_ALBUM, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_ARTIST, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_AUTHOR, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, METADATA_TYPE_LONG); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_COMPOSER, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_COMPILATION, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_DATE, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER, METADATA_TYPE_LONG); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_DURATION, METADATA_TYPE_LONG); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_YEAR, METADATA_TYPE_LONG); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_GENRE, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_TITLE, METADATA_TYPE_TEXT); EDITOR_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_WRITER, METADATA_TYPE_TEXT); }
From source file:com.namelessdev.mpdroid.NotificationService.java
/** * Update the remote controls./*from w w w. j a va 2 s . c o m*/ * * @param mpdStatus The current server status object. */ private void updateRemoteControlClient(final MPDStatus mpdStatus) { final int state = getRemoteState(mpdStatus); mRemoteControlClient.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, mCurrentMusic.getAlbum()) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, mCurrentMusic.getAlbumArtist()) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, mCurrentMusic.getArtist()) .putLong(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, (long) mCurrentMusic.getTrack()) .putLong(MediaMetadataRetriever.METADATA_KEY_DISC_NUMBER, (long) mCurrentMusic.getDisc()) .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, mCurrentMusic.getTime() * DateUtils.SECOND_IN_MILLIS) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, mCurrentMusic.getTitle()) .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, mAlbumCover).apply(); /** Notify of the elapsed time if on 4.3 or higher */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { mRemoteControlClient.setPlaybackState(state, lastKnownElapsed, 1.0f); } else { mRemoteControlClient.setPlaybackState(state); } Log.d(TAG, "Updated remote client with state " + state + " for music " + mCurrentMusic); }
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();/*from w w w . j a va 2 s .co m*/ //Set cover too? localRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); LOG.debug("Focus: updated meta-data"); }
From source file:org.videolan.vlc2.audio.AudioService.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateRemoteControlClientMetadata() { if (!LibVlcUtil.isICSOrLater()) // NOP check return;//from w w w.ja v a 2s .c om 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_ALBUMARTIST, 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(); } }
From source file:org.videolan.vlc.PlaybackService.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateRemoteControlClientMetadata() { if (!AndroidUtil.isICSOrLater()) // NOP check return;// w ww .j a va2 s . co m 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); } }
From source file:org.moire.ultrasonic.service.DownloadServiceImpl.java
private void updateRemoteControl() { if (!Util.isLockScreenEnabled(this)) { clearRemoteControl();//w w w . jav a 2 s. com return; } if (remoteControlClient != null) { audioManager.unregisterRemoteControlClient(remoteControlClient); audioManager.registerRemoteControlClient(remoteControlClient); } else { setUpRemoteControlClient(); } Log.i(TAG, String.format("In updateRemoteControl, playerState: %s [%d]", playerState, getPlayerPosition())); switch (playerState) { case STARTED: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } else { remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING, getPlayerPosition(), 1.0f); } break; default: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); } else { remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED, getPlayerPosition(), 1.0f); } break; } if (currentPlaying != null) { MusicDirectory.Entry currentSong = currentPlaying.getSong(); Bitmap lockScreenBitmap = FileUtil.getAlbumArtBitmap(this, currentSong, Util.getMinDisplayMetric(this), true); String artist = currentSong.getArtist(); String album = currentSong.getAlbum(); String title = currentSong.getTitle(); Integer currentSongDuration = currentSong.getDuration(); Long duration = 0L; if (currentSongDuration != null) duration = (long) currentSongDuration * 1000; remoteControlClient.editMetadata(true).putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artist) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, artist) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, album) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title) .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration) .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, lockScreenBitmap).apply(); } }
From source file:org.tomahawk.tomahawk_android.services.PlaybackService.java
/** * Update the playback controls/views which are being shown on the lockscreen *//*from ww w. ja v a 2s . com*/ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void updateLockscreenControls() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { Log.d(TAG, "updateLockscreenControls()"); // Use the media button APIs (if available) to register ourselves for media button // events MediaButtonHelper.registerMediaButtonEventReceiverCompat(mAudioManager, mMediaButtonReceiverComponent); if (mRemoteControlClientCompat == null) { Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); intent.setComponent(mMediaButtonReceiverComponent); mRemoteControlClientCompat = new RemoteControlClientCompat( PendingIntent.getBroadcast(PlaybackService.this /*context*/, 0 /*requestCode, ignored*/, intent /*intent*/, 0 /*flags*/)); RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat); } // Use the remote control APIs (if available) to set the playback state if (isPlaying()) { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); } else { mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED); } int flags = RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE; if (hasNextEntry()) { flags |= RemoteControlClient.FLAG_KEY_MEDIA_NEXT; } if (hasPreviousEntry()) { flags |= RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS; } mRemoteControlClientCompat.setTransportControlFlags(flags); // Update the remote controls synchronized (this) { RemoteControlClientCompat.MetadataEditorCompat editor = mRemoteControlClientCompat .editMetadata(true); editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, getCurrentQuery().getArtist().getPrettyName()) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getCurrentQuery().getArtist().getPrettyName()) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getCurrentQuery().getPrettyName()) .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, getCurrentQuery().getPreferredTrack().getDuration()); if (!TextUtils.isEmpty(getCurrentQuery().getAlbum().getPrettyName())) { editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getCurrentQuery().getAlbum().getPrettyName()); } editor.apply(); Log.d(TAG, "Setting lockscreen metadata to: " + getCurrentQuery().getArtist().getPrettyName() + ", " + getCurrentQuery().getPrettyName()); } Picasso.with(TomahawkApp.getContext()).cancelRequest(mLockscreenTarget); ImageUtils.loadImageIntoBitmap(TomahawkApp.getContext(), getCurrentQuery().getImage(), mLockscreenTarget, Image.getLargeImageSize(), getCurrentQuery().hasArtistImage()); } }
From source file:com.andrew.apollo.MusicPlaybackService.java
private static void changeRemoteControlClientTask(MusicPlaybackService musicPlaybackService, int playState, long position) { // background portion Bitmap albumArt = musicPlaybackService.getAlbumArt(); // RemoteControlClient wants to recycle the bitmaps thrown at it, so we need // to make sure not to hand out our cache copy Bitmap.Config config = null;/*from w ww . j av a2 s. co m*/ if (albumArt != null) { config = albumArt.getConfig(); } if (config == null) { config = Bitmap.Config.ARGB_8888; } Bitmap bmpCopy = null; try { if (albumArt != null) { bmpCopy = albumArt.copy(config, false); } } catch (OutOfMemoryError e) { // ignore, can't do anything meaningful here } final Bitmap albumArtCopy = bmpCopy; final String artistName = musicPlaybackService.getArtistName(); final String albumName = musicPlaybackService.getAlbumName(); final String trackName = musicPlaybackService.getTrackName(); final String albumArtistName = musicPlaybackService.getAlbumArtistName(); final long duration = musicPlaybackService.duration(); // MusicPlayerHandler thread portion, we can't put this as a PostContextTask // in Async.async. final WeakReference<MusicPlaybackService> musicPlaybackServiceRef = Ref.weak(musicPlaybackService); Runnable postExecute = () -> { if (!Ref.alive(musicPlaybackServiceRef)) { return; } MusicPlaybackService musicPlaybackService1 = musicPlaybackServiceRef.get(); try { RemoteControlClient.MetadataEditor editor = musicPlaybackService1.mRemoteControlClient .editMetadata(true).putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, artistName) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, albumArtistName) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, albumName) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, trackName) .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration); if (albumArtCopy != null) { editor.putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, albumArtCopy); } editor.apply(); } catch (Throwable t) { // possible NPE on android.media.RemoteControlClient$MetadataEditor.apply() } musicPlaybackService1.mRemoteControlClient.setPlaybackState(playState, position, 1.0f); }; musicPlaybackService.mPlayerHandler.post(postExecute); }