android.support.v4.media.MediaMetadataCompat Java Examples
The following examples show how to use
android.support.v4.media.MediaMetadataCompat.
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: MediaControllerService.java From Noyze with Apache License 2.0 | 8 votes |
@Produce public Pair<MediaMetadataCompat, PlaybackStateCompat> produceEvent() { final MediaMetadataCompat metadata; if (null == mController.getMetadata()) { metadata = (new MediaMetadataCompat.Builder()).build(); } else { // If the notification didn't provide an icon, add one! MediaMetadataCompat metadata1 = mController.getMetadata(); String packageName = metadata1.getString(RemoteControlCompat.METADATA_KEY_PACKAGE); if (!metadata1.containsKey(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON) && mLargeIconMap.containsKey(packageName)) { MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(metadata1); builder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, mLargeIconMap.get(packageName)); metadata1 = builder.build(); } metadata = metadata1; } return Pair.create(metadata, mController.getPlaybackState()); }
Example #2
Source File: MediaStyleHelper.java From AndroidAudioExample with MIT License | 6 votes |
/** * Build a notification using the information from the given media session. Makes heavy use * of {@link MediaMetadataCompat#getDescription()} to extract the appropriate information. * * @param context Context used to construct the notification. * @param mediaSession Media session to get information. * @return A pre-built notification with information from the given media session. */ static NotificationCompat.Builder from(Context context, MediaSessionCompat mediaSession) { MediaControllerCompat controller = mediaSession.getController(); MediaMetadataCompat mediaMetadata = controller.getMetadata(); MediaDescriptionCompat description = mediaMetadata.getDescription(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder .setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()) .setSubText(description.getDescription()) .setLargeIcon(description.getIconBitmap()) .setContentIntent(controller.getSessionActivity()) .setDeleteIntent( MediaButtonReceiver.buildMediaButtonPendingIntent(context, PlaybackStateCompat.ACTION_STOP)) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); return builder; }
Example #3
Source File: MediaBrowserHelper.java From android-MediaBrowserService with Apache License 2.0 | 6 votes |
public void registerCallback(Callback callback) { if (callback != null) { mCallbackList.add(callback); // Update with the latest metadata/playback state. if (mMediaController != null) { final MediaMetadataCompat metadata = mMediaController.getMetadata(); if (metadata != null) { callback.onMetadataChanged(metadata); } final PlaybackStateCompat playbackState = mMediaController.getPlaybackState(); if (playbackState != null) { callback.onPlaybackStateChanged(playbackState); } } } }
Example #4
Source File: MusicProvider.java From LyricHere with Apache License 2.0 | 6 votes |
private synchronized void buildListsByAlbum() { ConcurrentMap<String, List<MediaMetadataCompat>> newMusicListByAlbum = new ConcurrentHashMap<>(); for (MutableMediaMetadata m : mMusicListById.values()) { String album = m.metadata.getString(MediaMetadataCompat.METADATA_KEY_ALBUM); List<MediaMetadataCompat> list = newMusicListByAlbum.get(album); if (list == null) { list = new ArrayList<>(); newMusicListByAlbum.put(album, list); } list.add(m.metadata); } mMusicListByAlbum = newMusicListByAlbum; }
Example #5
Source File: VolumePanel.java From Noyze with Apache License 2.0 | 6 votes |
/** * Notified when the play state has changed. Unfortunately, without a standardized API this * may or may not be called (with or without all fields), and may only work for certain * apps/ music players. */ public void onPlayStateChanged(Pair<MediaMetadataCompat, PlaybackStateCompat> mediaInfo) { LOGI("VolumePanel", "onPlayStateChanged()"); // If the event was just an update to the play state, handle accordingly. mMusicActive = RemoteControlCompat.isPlaying(mediaInfo.second); LOGI("VolumePanel", "isPlayState(playing=" + mMusicActive + ")"); // Update the play state if we've been given one. if (null != mAudioHelper && null == mediaInfo.second) mMusicActive = mAudioHelper.isLocalOrRemoteMusicActive(); // Update the music package name based on RemoteController/ magic. if (null != mediaInfo.first) musicPackageName = mediaInfo.first.getString(RemoteControlCompat.METADATA_KEY_PACKAGE); // TRACK: when the user starts and ends playing a song. mMediaInfo = mediaInfo; }
Example #6
Source File: MediaNotificationManager.java From AndroidChromium with Apache License 2.0 | 6 votes |
private MediaMetadataCompat createMetadata() { MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, mMediaNotificationInfo.metadata.getTitle()); metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, mMediaNotificationInfo.origin); } else { metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, mMediaNotificationInfo.metadata.getTitle()); metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, mMediaNotificationInfo.origin); } if (!TextUtils.isEmpty(mMediaNotificationInfo.metadata.getArtist())) { metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, mMediaNotificationInfo.metadata.getArtist()); } if (!TextUtils.isEmpty(mMediaNotificationInfo.metadata.getAlbum())) { metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, mMediaNotificationInfo.metadata.getAlbum()); } return metadataBuilder.build(); }
Example #7
Source File: PlaybackControlsFragment.java From LyricHere with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_playback_controls, container, false); rootView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), FullScreenPlayerActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); MediaMetadataCompat metadata = mMediaControllerProvider. getSupportMediaController().getMetadata(); if (metadata != null) { intent.putExtra(MusicPlayerActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION, metadata.getDescription()); } startActivity(intent); } }); return rootView; }
Example #8
Source File: VolumePanel.java From Noyze with Apache License 2.0 | 6 votes |
/** * Notified when the play state has changed. Unfortunately, without a standardized API this * may or may not be called (with or without all fields), and may only work for certain * apps/ music players. */ public void onPlayStateChanged(Pair<MediaMetadataCompat, PlaybackStateCompat> mediaInfo) { LOGI("VolumePanel", "onPlayStateChanged()"); // If the event was just an update to the play state, handle accordingly. mMusicActive = RemoteControlCompat.isPlaying(mediaInfo.second); LOGI("VolumePanel", "isPlayState(playing=" + mMusicActive + ")"); // Update the play state if we've been given one. if (null != mAudioHelper && null == mediaInfo.second) mMusicActive = mAudioHelper.isLocalOrRemoteMusicActive(); // Update the music package name based on RemoteController/ magic. if (null != mediaInfo.first) musicPackageName = mediaInfo.first.getString(RemoteControlCompat.METADATA_KEY_PACKAGE); // TRACK: when the user starts and ends playing a song. mMediaInfo = mediaInfo; }
Example #9
Source File: RemoteControlCompat.java From Noyze with Apache License 2.0 | 6 votes |
/** * @return The {@link android.graphics.Bitmap} references by {@link android.support.v4.media.MediaMetadataCompat} * @throws FileNotFoundException If an error parsing the {@link android.net.Uri} occurred. */ public static Bitmap getBitmap(Context context, MediaMetadataCompat metadata) throws FileNotFoundException{ if (null == metadata) return null; Bitmap albumArtBitmap = metadata.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART); // No album art... check the URI. if (null == albumArtBitmap) { String albumArtUri = metadata.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI); // Still no URI... check the art URI. if (TextUtils.isEmpty(albumArtUri)) albumArtUri = metadata.getString(MediaMetadataCompat.METADATA_KEY_ART_URI); // If we've got a URI, try to load it. if (!TextUtils.isEmpty(albumArtUri)) { ContentResolver cr = context.getContentResolver(); albumArtBitmap = BitmapFactory.decodeStream(cr.openInputStream(Uri.parse(albumArtUri))); } } return albumArtBitmap; }
Example #10
Source File: TrackNotification.java From Melophile with Apache License 2.0 | 6 votes |
private Notification createNotification() { if (mediaMetadata == null || playbackState == null) return null; NotificationCompat.Builder builder = new NotificationCompat.Builder(service); builder.setStyle(new NotificationCompat.MediaStyle() .setMediaSession(token) .setShowActionsInCompactView(1)) .setColor(Color.WHITE) .setPriority(Notification.PRIORITY_MAX) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setUsesChronometer(true) .setDeleteIntent(dismissedNotification(service)) .setSmallIcon(R.drawable.ic_music_note) .setContentIntent(contentIntent(service)) .setContentTitle(mediaMetadata.getString(MediaMetadataCompat.METADATA_KEY_ARTIST)) .setContentText(mediaMetadata.getString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE)) .addAction(prev(service)); if (playbackState.getState() == PlaybackStateCompat.STATE_PLAYING) { builder.addAction(pause(service)); } else { builder.addAction(play(service)); } builder.addAction(next(service)); setNotificationPlaybackState(builder); loadImage(mediaMetadata.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI), builder); return builder.build(); }
Example #11
Source File: PlaybackServiceStatusHelper.java From odyssey with GNU General Public License v3.0 | 6 votes |
/** * Starts the cover fetching task. Make sure that mLastTrack is set correctly before. */ private void startCoverImageTask() { // Try to get old metadata to save image retrieval. MediaMetadataCompat oldData = mMediaSession.getController().getMetadata(); MediaMetadataCompat.Builder metaDataBuilder; if (oldData == null) { metaDataBuilder = new MediaMetadataCompat.Builder(); } else { metaDataBuilder = new MediaMetadataCompat.Builder(mMediaSession.getController().getMetadata()); } // Reset metadata image in case covergenerator fails metaDataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null); mMediaSession.setMetadata(metaDataBuilder.build()); // Start the actual task based on the current track. (mLastTrack get sets before in updateStatus()) mCoverLoader.getImage(mLastTrack, -1, -1); }
Example #12
Source File: MediaNotificationManager.java From 365browser with Apache License 2.0 | 6 votes |
@Nullable private MediaMetadataCompat createMetadata() { if (mMediaNotificationInfo.isPrivate) return null; MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder(); metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, mMediaNotificationInfo.metadata.getTitle()); metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, mMediaNotificationInfo.origin); if (!TextUtils.isEmpty(mMediaNotificationInfo.metadata.getArtist())) { metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, mMediaNotificationInfo.metadata.getArtist()); } if (!TextUtils.isEmpty(mMediaNotificationInfo.metadata.getAlbum())) { metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, mMediaNotificationInfo.metadata.getAlbum()); } if (mMediaNotificationInfo.mediaSessionImage != null) { metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, mMediaNotificationInfo.mediaSessionImage); } return metadataBuilder.build(); }
Example #13
Source File: RemoteControlCompat.java From Noyze with Apache License 2.0 | 5 votes |
/** @see {@link #getBitmap(android.content.Context, android.support.v4.media.MediaMetadataCompat)} */ public static Bitmap getIcon(Context context, MediaMetadataCompat metadata) throws FileNotFoundException{ if (null == metadata) return null; Bitmap albumArtBitmap = metadata.getBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON); // No icon... check the URI. if (null == albumArtBitmap) { String albumArtUri = metadata.getString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI); // If we've got a URI, try to load it. if (!TextUtils.isEmpty(albumArtUri)) { ContentResolver cr = context.getContentResolver(); albumArtBitmap = BitmapFactory.decodeStream(cr.openInputStream(Uri.parse(albumArtUri))); } } return albumArtBitmap; }
Example #14
Source File: RNAudioPlayerModule.java From react-native-streaming-audio-player with MIT License | 5 votes |
@ReactMethod public void play(String stream_url, ReadableMap metadata) { Bundle bundle = new Bundle(); bundle.putString(MediaMetadataCompat.METADATA_KEY_TITLE, metadata.getString("title")); bundle.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, metadata.getString("album_art_uri")); bundle.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, metadata.getString("artist")); mMediaController.getTransportControls().playFromUri(Uri.parse(stream_url), bundle); }
Example #15
Source File: MediaNotificationManager.java From YouTube-In-Background with MIT License | 5 votes |
/** * Posts the notification and starts tracking the session to keep it * updated. The notification will automatically be removed if the session is * destroyed before {@link #stopNotification} is called. */ public void startNotification() { if (!hasRegisterReceiver) { currentYouTubeVideo = exoAudioService.getCurrentYouTubeVideo(); MediaMetadataCompat metadata = mediaController.getMetadata(); LogHelper.e(TAG, "metadata: " + metadata); playbackState = mediaController.getPlaybackState(); // The notification must be updated after setting started to true // Notification notification = createNotification(); updateNotification(mediaController.getPlaybackState()); // if (notification != null) { // mediaController.registerCallback(callback); // IntentFilter filter = new IntentFilter(); // filter.addAction(CUSTOM_ACTION_NEXT); // filter.addAction(CUSTOM_ACTION_PAUSE); // filter.addAction(CUSTOM_ACTION_PLAY); // filter.addAction(CUSTOM_ACTION_PREV); // filter.addAction(CUSTOM_ACTION_STOP); // exoAudioService.registerReceiver(this, filter); // // exoAudioService.startForeground(NOTIFICATION_ID, notification); // hasRegisterReceiver = true; // } } }
Example #16
Source File: RemoteControlCompat.java From Noyze with Apache License 2.0 | 5 votes |
/** @return {@link android.support.v4.media.MediaMetadataCompat} log info (what keys it contains). */ public static String getMediaMetadataLog(MediaMetadataCompat metadata) { if (null == metadata) return ""; final String[] METADATA_KEYS = new String[] { MediaMetadataCompat.METADATA_KEY_ALBUM, MediaMetadataCompat.METADATA_KEY_ALBUM_ART, MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, MediaMetadataCompat.METADATA_KEY_ART, MediaMetadataCompat.METADATA_KEY_ARTIST, MediaMetadataCompat.METADATA_KEY_ART_URI, MediaMetadataCompat.METADATA_KEY_AUTHOR, MediaMetadataCompat.METADATA_KEY_COMPILATION, MediaMetadataCompat.METADATA_KEY_COMPOSER, MediaMetadataCompat.METADATA_KEY_DATE, MediaMetadataCompat.METADATA_KEY_DISC_NUMBER, MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI, MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, MediaMetadataCompat.METADATA_KEY_DURATION, MediaMetadataCompat.METADATA_KEY_GENRE, MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, MediaMetadataCompat.METADATA_KEY_RATING, MediaMetadataCompat.METADATA_KEY_TITLE, MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, MediaMetadataCompat.METADATA_KEY_USER_RATING, MediaMetadataCompat.METADATA_KEY_WRITER, MediaMetadataCompat.METADATA_KEY_YEAR }; StringBuffer builder = new StringBuffer("{"); for (String key : METADATA_KEYS) builder.append(key).append('=').append( (metadata.containsKey(key)) ? metadata.getText(key) : false).append(','); builder.append('}'); return builder.toString(); }
Example #17
Source File: MediaNotificationManager.java From YouTube-In-Background with MIT License | 5 votes |
@Override public void onMetadataChanged(MediaMetadataCompat metadata) { LogHelper.e(TAG, "Received new metadata ", metadata.getDescription()); MediaNotificationManager.this.currentYouTubeVideo = exoAudioService.getCurrentYouTubeVideo(); updateNotification(mediaController.getPlaybackState()); // Notification notification = createNotification(); // if (notification != null) { // notificationManager.notify(NOTIFICATION_ID, notification); // } }
Example #18
Source File: RadioPlayerService.java From monkeyboard-radio-android with GNU General Public License v3.0 | 5 votes |
private void createNewPlaybackMetadataForStation(RadioStation station) { if (mediaSession != null) { if (getMediaController().getMetadata() != null) { // Check for infinite loops due to callbacks if (getMediaController() .getMetadata() .getLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER) == station.getFrequency()) { return; } } mediaSession.setMetadata( new MediaMetadataCompat.Builder() .putString(MediaMetadataCompat.METADATA_KEY_TITLE, station.getName()) .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, station.getEnsemble()) .putString(MediaMetadataCompat.METADATA_KEY_GENRE, RadioDevice.StringValues.getGenreFromId( station.getGenreId() ) ) .putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, station.getFrequency()) .build() ); } }
Example #19
Source File: MetadataMapper.java From Melophile with Apache License 2.0 | 5 votes |
@Override public MediaMetadataCompat map(Track track) { if (track == null) return null; return new MediaMetadataCompat.Builder() .putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, track.getArtworkUrl()) .putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, track.getTitle()) .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, track.getArtist()) .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, Long.parseLong(track.getDuration())) .putString(MediaMetadataCompat.METADATA_KEY_DATE, track.getReleaseDate()) .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI, track.getStreamUrl()) .putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, track.getId()).build(); }
Example #20
Source File: MetadataMapper.java From Melophile with Apache License 2.0 | 5 votes |
@Override public Track reverse(MediaMetadataCompat metadataCompat) { if (metadataCompat == null) return null; Track track = new Track(); track.setArtist(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_ARTIST)); track.setArtworkUrl(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI)); track.setDuration(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_DURATION)); track.setReleaseDate(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_DATE)); track.setStreamUrl(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI)); track.setId(metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID)); return track; }
Example #21
Source File: MediaSessionWrapper.java From Cheerleader with Apache License 2.0 | 5 votes |
/** * Update meta data used by the remote control client and the media session. * * @param track track currently played. * @param artwork track artwork. */ @SuppressWarnings("deprecation") public void setMetaData(SoundCloudTrack track, Bitmap artwork) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // set meta data on the lock screen for pre lollipop. mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING); RemoteControlClientCompat.MetadataEditorCompat mediaEditorCompat = mRemoteControlClientCompat.editMetadata(true) .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, track.getTitle()) .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, track.getArtist()); if (artwork != null) { mediaEditorCompat.putBitmap( RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK, artwork); } mediaEditorCompat.apply(); } // set meta data to the media session. MediaMetadataCompat.Builder metadataCompatBuilder = new MediaMetadataCompat.Builder() .putString(MediaMetadataCompat.METADATA_KEY_TITLE, track.getTitle()) .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, track.getArtist()); if (artwork != null) { metadataCompatBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, artwork); } mMediaSession.setMetadata(metadataCompatBuilder.build()); setMediaSessionCompatPlaybackState(PlaybackStateCompat.STATE_PLAYING); }
Example #22
Source File: BackgroundExoAudioService.java From YouTube-In-Background with MIT License | 5 votes |
private MediaMetadataCompat getVideoMetadata() { if (currentYouTubeVideo == null) return null; MediaMetadataCompat.Builder ytVideo = new MediaMetadataCompat.Builder(); ytVideo.putString(METADATA_KEY_DISPLAY_TITLE, currentYouTubeVideo.getTitle()); ytVideo.putString(METADATA_KEY_DISPLAY_SUBTITLE, currentYouTubeVideo.getViewCount()); ytVideo.putString(METADATA_KEY_DISPLAY_ICON_URI, currentYouTubeVideo.getThumbnailURL()); ytVideo.putString(METADATA_KEY_MEDIA_ID, currentYouTubeVideo.getId()); ytVideo.putLong(METADATA_KEY_DURATION, playbackManager.getDuration()); return ytVideo.build(); }
Example #23
Source File: PlaybackManager.java From Melophile with Apache License 2.0 | 5 votes |
private void updateMetadata() { if (updateListener != null) { MediaMetadataCompat result = new MediaMetadataCompat.Builder(mapper.map(queueManager.current())) .putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, queueManager.size()) .putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, queueManager.currentIndex() + 1) .putLong(MediaMetadataCompat.METADATA_KEY_DISC_NUMBER, playback.getPosition()) .build(); updateListener.onMetadataChanged(result); } }
Example #24
Source File: MusicProvider.java From LyricHere with Apache License 2.0 | 5 votes |
/** * Get music tracks of the given genre */ public Iterable<MediaMetadataCompat> getMusicsByAlbum(String album) { if (mCurrentState != State.INITIALIZED || !mMusicListByAlbum.containsKey(album)) { return Collections.emptyList(); } return mMusicListByAlbum.get(album); }
Example #25
Source File: PlayerService.java From AndroidAudioExample with MIT License | 5 votes |
private void updateMetadataFromTrack(MusicRepository.Track track) { metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, BitmapFactory.decodeResource(getResources(), track.getBitmapResId())); metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, track.getTitle()); metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, track.getArtist()); metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, track.getArtist()); metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, track.getDuration()); mediaSession.setMetadata(metadataBuilder.build()); }
Example #26
Source File: MediaSessionCompat.java From letv with Apache License 2.0 | 5 votes |
private void sendMetadata(MediaMetadataCompat metadata) { for (int i = this.mControllerCallbacks.beginBroadcast() - 1; i >= 0; i--) { try { ((IMediaControllerCallback) this.mControllerCallbacks.getBroadcastItem(i)).onMetadataChanged(metadata); } catch (RemoteException e) { } } this.mControllerCallbacks.finishBroadcast(); }
Example #27
Source File: FullScreenPlayerActivity.java From LyricHere with Apache License 2.0 | 5 votes |
private void updateDuration(MediaMetadataCompat metadata) { if (metadata == null) { return; } LogUtils.d(TAG, "updateDuration called "); int duration = (int) metadata.getLong(MediaMetadataCompat.METADATA_KEY_DURATION); mSeekBar.setMax(duration); mEnd.setText(Utils.formatMillis(duration)); }
Example #28
Source File: MediaBrowserFragment.java From LyricHere with Apache License 2.0 | 5 votes |
@Override public void onMetadataChanged(MediaMetadataCompat metadata) { super.onMetadataChanged(metadata); if (metadata == null) { return; } LogUtils.d(TAG, "Received metadata change to media ", metadata.getDescription().getMediaId()); mBrowserAdapter.notifyDataSetChanged(); }
Example #29
Source File: BlackberryVolumePanel.java From Noyze with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") @Subscribe public void onPlaybackEvent(Pair<MediaMetadataCompat, PlaybackStateCompat> mediaInfo) { // NOTE: This MUST be added to the final descendant of VolumePanel! LOGI(TAG, "onPlaybackEvent()"); this.onPlayStateChanged(mediaInfo); }
Example #30
Source File: MainActivity.java From YouTube-In-Background with MIT License | 5 votes |
@Override public void onMetadataChanged(MediaMetadataCompat metadata) { LogHelper.e(TAG, "onMetadataChanged"); if (shouldShowControls()) { showPlaybackControls(); } else { LogHelper.e(TAG, "onMetadataChanged: hiding controls because metadata is null"); hidePlaybackControls(); } }