List of usage examples for android.media MediaMetadata METADATA_KEY_ALBUM_ARTIST
String METADATA_KEY_ALBUM_ARTIST
To view the source code for android.media MediaMetadata METADATA_KEY_ALBUM_ARTIST.
Click Source Link
From source file:com.orangesoft.jook.CastPlayback.java
/** * Helper method to convert a {@link android.media.MediaMetadata} to a * {@link com.google.android.gms.cast.MediaInfo} used for sending media to the receiver app. * * @param track {@link com.google.android.gms.cast.MediaMetadata} * @param customData custom data specifies the local mediaId used by the player. * @return mediaInfo {@link com.google.android.gms.cast.MediaInfo} *//* w ww . j a va 2 s . co m*/ private static MediaInfo toCastMediaMetadata(MediaMetadata track, JSONObject customData) { com.google.android.gms.cast.MediaMetadata metadata = new com.google.android.gms.cast.MediaMetadata( com.google.android.gms.cast.MediaMetadata.MEDIA_TYPE_MUSIC_TRACK); metadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_TITLE, track.getDescription().getTitle() == null ? "" : track.getDescription().getTitle().toString()); metadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_SUBTITLE, track.getDescription().getSubtitle() == null ? "" : track.getDescription().getSubtitle().toString()); metadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_ARTIST, track.getString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST)); metadata.putString(com.google.android.gms.cast.MediaMetadata.KEY_ALBUM_TITLE, track.getString(MediaMetadata.METADATA_KEY_ALBUM)); WebImage image = new WebImage( new Uri.Builder().encodedPath(track.getString(MediaMetadata.METADATA_KEY_ALBUM_ART_URI)).build()); // First image is used by the receiver for showing the audio album art. metadata.addImage(image); // Second image is used by Cast Companion Library on the full screen activity that is shown // when the cast dialog is clicked. metadata.addImage(image); return new MediaInfo.Builder(track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE)) .setContentType(MIME_TYPE_AUDIO_MPEG).setStreamType(MediaInfo.STREAM_TYPE_BUFFERED) .setMetadata(metadata).setCustomData(customData).build(); }
From source file:com.av.remusic.service.MediaService.java
private void updateMediaSession(final String what) { int playState = mIsSupposedToBePlaying ? PlaybackState.STATE_PLAYING : PlaybackState.STATE_PAUSED; if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mSession.setPlaybackState(new PlaybackState.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS) .build());//from www .ja v a 2 s . c o m } } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) { //Bitmap albumArt = ImageLoader.getInstance().loadImageSync(CommonUtils.getAlbumArtUri(getAlbumId()).toString()); Bitmap albumArt = null; if (albumArt != null) { Bitmap.Config config = albumArt.getConfig(); if (config == null) { config = Bitmap.Config.ARGB_8888; } albumArt = albumArt.copy(config, false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mSession.setMetadata( new MediaMetadata.Builder().putString(MediaMetadata.METADATA_KEY_ARTIST, getArtistName()) .putString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST, getAlbumArtistName()) .putString(MediaMetadata.METADATA_KEY_ALBUM, getAlbumName()) .putString(MediaMetadata.METADATA_KEY_TITLE, getTrackName()) .putLong(MediaMetadata.METADATA_KEY_DURATION, duration()) .putLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER, getQueuePosition() + 1) .putLong(MediaMetadata.METADATA_KEY_NUM_TRACKS, getQueue().length) .putString(MediaMetadata.METADATA_KEY_GENRE, getGenreName()) .putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, mShowAlbumArtOnLockscreen ? albumArt : null) .build()); mSession.setPlaybackState(new PlaybackState.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS) .build()); } } }