Example usage for android.media RemoteControlClient PLAYSTATE_PLAYING

List of usage examples for android.media RemoteControlClient PLAYSTATE_PLAYING

Introduction

In this page you can find the example usage for android.media RemoteControlClient PLAYSTATE_PLAYING.

Prototype

int PLAYSTATE_PLAYING

To view the source code for android.media RemoteControlClient PLAYSTATE_PLAYING.

Click Source Link

Document

Playback state of a RemoteControlClient which is playing media.

Usage

From source file:de.qspool.clementineremote.backend.ClementinePlayerConnection.java

/**
 * Update the RemoteControlClient/*from   w w w.j a v a2  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.andreadec.musicplayer.MusicService.java

private void updateNotificationMessage() {
    /* Update remote control client */
    if (Build.VERSION.SDK_INT >= 14) {
        if (currentPlayingItem == null) {
            remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
        } else {/* w  w w. j  a  v  a 2 s . c  o m*/
            if (isPlaying()) {
                remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
            } else {
                remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
            }
            RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
            metadataEditor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, currentPlayingItem.getTitle());
            metadataEditor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, currentPlayingItem.getArtist());
            metadataEditor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST,
                    currentPlayingItem.getArtist());
            metadataEditor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, getDuration());
            if (currentPlayingItem.hasImage()) {
                metadataEditor.putBitmap(METADATA_KEY_ARTWORK, currentPlayingItem.getImage());
            } else {
                metadataEditor.putBitmap(METADATA_KEY_ARTWORK, icon.copy(icon.getConfig(), false));
            }
            metadataEditor.apply();
        }
    }

    /* Update notification */
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder.setSmallIcon(R.drawable.audio_white);
    //notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    notificationBuilder.setOngoing(true);

    int playPauseIcon = isPlaying() ? R.drawable.pause : R.drawable.play;
    //int playPauseString = isPlaying() ? R.string.pause : R.string.play;
    notificationBuilder.setContentIntent(pendingIntent);

    String notificationMessage = "";
    if (currentPlayingItem == null) {
        notificationMessage = getResources().getString(R.string.noSong);
    } else {
        if (currentPlayingItem.getArtist() != null && !currentPlayingItem.getArtist().equals(""))
            notificationMessage = currentPlayingItem.getArtist() + " - ";
        notificationMessage += currentPlayingItem.getTitle();
    }

    /*notificationBuilder.addAction(R.drawable.previous, getResources().getString(R.string.previous), previousPendingIntent);
    notificationBuilder.addAction(playPauseIcon, getResources().getString(playPauseString), playpausePendingIntent);
    notificationBuilder.addAction(R.drawable.next, getResources().getString(R.string.next), nextPendingIntent);*/
    notificationBuilder.setContentTitle(getResources().getString(R.string.app_name));
    notificationBuilder.setContentText(notificationMessage);

    notification = notificationBuilder.build();

    RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.layout_notification);

    if (currentPlayingItem == null) {
        notificationLayout.setTextViewText(R.id.textViewArtist, getString(R.string.app_name));
        notificationLayout.setTextViewText(R.id.textViewTitle, getString(R.string.noSong));
        notificationLayout.setImageViewBitmap(R.id.imageViewNotification,
                BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    } else {
        notificationLayout.setTextViewText(R.id.textViewArtist, currentPlayingItem.getArtist());
        notificationLayout.setTextViewText(R.id.textViewTitle, currentPlayingItem.getTitle());
        Bitmap image = currentPlayingItem.getImage();
        if (image != null) {
            notificationLayout.setImageViewBitmap(R.id.imageViewNotification, image);
        } else {
            notificationLayout.setImageViewBitmap(R.id.imageViewNotification,
                    BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
        }
    }
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationQuit, quitPendingIntent);
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationPrevious, previousPendingIntent);
    notificationLayout.setImageViewResource(R.id.buttonNotificationPlayPause, playPauseIcon);
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationPlayPause, playpausePendingIntent);
    notificationLayout.setOnClickPendingIntent(R.id.buttonNotificationNext, nextPendingIntent);
    notification.bigContentView = notificationLayout;

    notificationManager.notify(Constants.NOTIFICATION_MAIN, notification);
}

From source file:co.shunya.gita.player.MusicService.java

/**
 * Starts playing the next song. If manualUrl is null, the next song will be randomly selected
 * from our Media Retriever (that is, it will be a random song in the user's device). If
 * manualUrl is non-null, then it specifies the URL or path to the song that will be played
 * next./*  w w w.  ja  v  a 2s  .c  o  m*/
 */
void playNextSong(Long id) {
    if (id == null || id < 0) {
        throw new IllegalArgumentException("id must be non nul +ve");
    }
    setState(State.Stopped);
    relaxResources(false); // release everything except MediaPlayer

    try {
        // set the source of the media player to a manual URL or path
        Track playingItem = mRetriever.getItem(id);
        createMediaPlayerIfNeeded();
        mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

        if (playingItem == null) {
            Toast.makeText(this, "All Tracks of current category is been played", Toast.LENGTH_LONG).show();
            processStopRequest(true); // stop everything!
            return;
        }
        //            BusProvider.getInstance().post(playingItem);
        mCurrentID = id;
        mPlayer.setDataSource(playingItem.isDownloded() ? playingItem.getLocalUrl(this) : playingItem.getUrl());
        mIsStreaming = playingItem.getUrl().startsWith("http:") || playingItem.getUrl().startsWith("https:");
        mSongTitle = playingItem.getTitle();

        setState(State.Preparing);
        updateUI();

        setUpAsForeground(mSongTitle + " (loading)");

        // Use the media button APIs (if available) to register ourselves for media button
        // events

        MediaButtonHelper.registerMediaButtonEventReceiverCompat(mAudioManager, mMediaButtonReceiverComponent);

        // Use the remote control APIs (if available) to set the playback state

        if (mRemoteControlClientCompat == null) {
            Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
            intent.setComponent(mMediaButtonReceiverComponent);
            mRemoteControlClientCompat = new RemoteControlClientCompat(PendingIntent.getBroadcast(
                    this /*context*/, 0 /*requestCode, ignored*/, intent /*intent*/, 0 /*flags*/));
            RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat);
        }

        mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

        mRemoteControlClientCompat.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY
                | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
                | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_STOP);

        // Update the remote controls
        mRemoteControlClientCompat.editMetadata(true)
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, "Gita")
                .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, playingItem.getTitle())
                .putBitmap(RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK, mDummyAlbumArt)
                .apply();

        // starts preparing the media player in the background. When it's done, it will call
        // our OnPreparedListener (that is, the onPrepared() method on this class, since we set
        // the listener to 'this').
        //
        // Until the media player is prepared, we *cannot* call start() on it!
        mPlayer.prepareAsync();

        // If we are streaming from the internet, we want to hold a Wifi lock, which prevents
        // the Wifi radio from going to sleep while the song is playing. If, on the other hand,
        // we are *not* streaming, we want to release the lock if we were holding it before.
        if (mIsStreaming)
            mWifiLock.acquire();
        else if (mWifiLock.isHeld())
            mWifiLock.release();
    } catch (IOException ex) {
        Log.e("MusicService", "IOException playing next song: " + ex.getMessage());
        ex.printStackTrace();
    }
}

From source file:com.example.android.mediarouter.player.MainActivity.java

private void updateButtons() {
    MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute();
    // show pause or resume icon depending on current state
    mPauseResumeButton.setImageResource(mPaused ? R.drawable.ic_action_play : R.drawable.ic_action_pause);
    // disable pause/resume/stop if no session
    mPauseResumeButton.setEnabled(mSessionManager.hasSession());
    mStopButton.setEnabled(mSessionManager.hasSession());
    // only enable seek bar when duration is known
    PlaylistItem item = getCheckedPlaylistItem();
    mSeekBar.setEnabled(item != null && item.getDuration() > 0);
    if (mRemoteControlClient != null) {
        mRemoteControlClient.setPlaybackState(
                mPaused ? RemoteControlClient.PLAYSTATE_PAUSED : RemoteControlClient.PLAYSTATE_PLAYING);
    }/*from   ww  w. ja v  a 2  s . co  m*/
}

From source file:com.example.android.mediarouter.player.RadioActivity.java

private void updateButtons() {
    RouteInfo route = mMediaRouter.getSelectedRoute();
    // show pause or resume icon depending on current state
    mPauseResumeButton.setImageResource(mPaused ? R.drawable.ic_action_play : R.drawable.ic_action_pause);
    // disable pause/resume/stop if no session
    mPauseResumeButton.setEnabled(mSessionManager.hasSession());
    mStopButton.setEnabled(mSessionManager.hasSession());
    // only enable seek bar when duration is known
    PlaylistItem item = getCheckedPlaylistItem();
    mSeekBar.setEnabled(item != null && item.getDuration() > 0);
    if (mRemoteControlClient != null) {
        mRemoteControlClient.setPlaybackState(
                mPaused ? RemoteControlClient.PLAYSTATE_PAUSED : RemoteControlClient.PLAYSTATE_PLAYING);
    }//  w w w.  j a va 2s.c  om
}

From source file:com.nd.android.u.square.service.MusicPlaybackService.java

/**
 * Starts playing the next song. If manualUrl is null, the next song will be randomly selected
 * from our Media Retriever (that is, it will be a random song in the user's device). If
 * manualUrl is non-null, then it specifies the URL or path to the song that will be played
 * next.//from  w ww.  j ava 2  s .  c  o  m
 */
void playNextSong(Item playingItem) {
    mState = State.Stopped;
    relaxResources(false); // release everything except MediaPlayer

    try {
        if (null == playingItem) {
            playingItem = pollNextSong(mPlayingItem);
            if (null == playingItem) {
                if (sOnStateChangedListener != null) {
                    sOnStateChangedListener.onPlayListIsEmpty();
                }
                return;
            }
            mPlayingItem = playingItem;

            if (null != sOnStateChangedListener)
                sOnStateChangedListener.onCurrentPlayingItemChanged(mPlayingItem);
        }

        // set the source of the media player a a content URI
        createMediaPlayerIfNeeded();
        mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mPlayer.setDataSource(playingItem.getUrl());
        mIsStreaming = true;
        mSongTitle = playingItem.title;
        mState = State.Preparing;
        setUpAsForeground(mSongTitle + "");

        // Use the media button APIs (if available) to register ourselves for media button
        // events

        MediaButtonHelper.registerMediaButtonEventReceiverCompat(mAudioManager, mMediaButtonReceiverComponent);

        // Use the remote control APIs (if available) to set the playback state

        if (mRemoteControlClientCompat == null) {
            Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
            intent.setComponent(mMediaButtonReceiverComponent);
            mRemoteControlClientCompat = new RemoteControlClientCompat(PendingIntent
                    .getBroadcast(this /*context*/, 0 /*requestCode, ignored*/, intent /*intent*/, 0 /*flags*/
            ));
            RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat);
        }

        mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

        mRemoteControlClientCompat.setTransportControlFlags(
                RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
                        | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP);

        // Update the remote controls
        mRemoteControlClientCompat.editMetadata(true)
                .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, playingItem.title)
                .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, playingItem.duration)
                // TODO: fetch real item artwork
                .putBitmap(RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK, mDummyAlbumArt)
                .apply();

        // starts preparing the media player in the background. When it's done, it will call
        // our OnPreparedListener (that is, the onPrepared() method on this class, since we set
        // the listener to 'this').
        //
        // Until the media player is prepared, we *cannot* call start() on it!
        mPlayingItem.bufferedPercent = 0;
        mPlayer.prepareAsync();

        if (null != sOnStateChangedListener)
            sOnStateChangedListener.onPlayerPreparing(mPlayingItem);

        // If we are streaming from the internet, we want to hold a Wifi lock, which prevents
        // the Wifi radio from going to sleep while the song is playing. If, on the other hand,
        // we are *not* streaming, we want to release the lock if we were holding it before.
        if (mIsStreaming)
            mWifiLock.acquire();
        else if (mWifiLock.isHeld())
            mWifiLock.release();
    } catch (IOException ex) {
        Log.e(TAG, "IOException playing next song: " + ex.getMessage(), ex);
    }
}

From source file:com.geryon.ocraa.MusicService.java

/**
 * Starts playing the next song. If manualUrl is null, the next song will be randomly selected
 * from our Media Retriever (that is, it will be a random song in the user's device). If
 * manualUrl is non-null, then it specifies the URL or path to the song that will be played
 * next./*from  ww  w.j  a va  2  s  .co m*/
 */
void playNextSong(int pos) {
    position = pos;
    mState = State.Stopped;
    progressBarHandler.removeCallbacks(mUpdateTimeTask);
    MusicRetriever.Item playingItem = null;
    relaxResources(false); // release everything except MediaPlayer

    try {
        if ((position == -1) || (repeat == false && shuffle == true)) {

            Random mRandom = new Random();

            int random = mRandom.nextInt(mRetriever.ItemSize());
            playingItem = mRetriever.getItem(random);
            Log.d("Randomize:", String.valueOf(random));
            position = random;
            Log.d("Position:", String.valueOf(random));
            if (playingItem == null) {
                Toast.makeText(this, "No available music to play. Place some music on your external storage "
                        + "device (e.g. your SD card) and try again.", Toast.LENGTH_LONG).show();
                processStopRequest(true); // stop everything!
                return;
            }

            createMediaPlayerIfNeeded();
            mPlayer.setDataSource(playingItem.getURI().toString());
        }

        else

        if (position != -1) {
            if (repeat == false) {
                if (shuffle == false) {
                    if (position == mRetriever.ItemSize() - 1) {
                        position = 0;
                    } else {
                        position++;
                    }

                }
            }
            playingItem = mRetriever.getItem(position);

            createMediaPlayerIfNeeded();

            mPlayer.setDataSource(playingItem.getURI().toString());

        }

        mSongTitle = playingItem.getTitle();

        mState = State.Preparing;
        setUpAsForeground(mSongTitle + " (loading)");

        // Use the media button APIs (if available) to register ourselves for media button
        // events

        MediaButtonHelper.registerMediaButtonEventReceiverCompat(mAudioManager, mMediaButtonReceiverComponent);

        // Use the remote control APIs (if available) to set the playback state

        if (mRemoteControlClientCompat == null) {
            Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
            intent.setComponent(mMediaButtonReceiverComponent);
            mRemoteControlClientCompat = new RemoteControlClientCompat(PendingIntent.getBroadcast(
                    this /*context*/, 0 /*requestCode, ignored*/, intent /*intent*/, 0 /*flags*/));
            RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat);
        }

        mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

        mRemoteControlClientCompat.setTransportControlFlags(
                RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
                        | RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_STOP);

        // Update the remote controls
        mRemoteControlClientCompat.editMetadata(true)
                .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, playingItem.getArtist())
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, playingItem.getAlbum())
                .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, playingItem.getTitle())
                .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, playingItem.getDuration())
                // TODO: fetch real item artwork
                .putBitmap(RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK, mDummyAlbumArt)
                .apply();

        // starts preparing the media player in the background. When it's done, it will call
        // our OnPreparedListener (that is, the onPrepared() method on this class, since we set
        // the listener to 'this').
        //
        // Until the media player is prepared, we *cannot* call start() on it!
        mPlayer.prepareAsync();
        updateProgressBar();
        // If we are streaming from the internet, we want to hold a Wifi lock, which prevents
        // the Wifi radio from going to sleep while the song is playing. If, on the other hand,
        // we are *not* streaming, we want to release the lock if we were holding it before.
        if (mIsStreaming)
            mWifiLock.acquire();
        else if (mWifiLock.isHeld())
            mWifiLock.release();
    } catch (IOException ex) {
        //  Log.e("MusicService", "IOException playing next song: " + ex.getMessage());
        // ex.printStackTrace();
    }
}

From source file:com.iamplus.musicplayer.MusicService.java

private void updateRemoteControlPlayingState() {
    // Tell any remote controls that our playback state is 'Playing'.
    if (mRemoteControlClientCompat != null) {
        mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

        // Update the remote controls
        //Bitmap bitmap = MediaAlbumsAdaptor.getAlbumArtwork(getApplicationContext(), mCurrentPlayingItem.getAlbumid(), true);
        mRemoteControlClientCompat.editMetadata(true)
                .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, mCurrentPlayingItem.getArtist())
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, mCurrentPlayingItem.getAlbum())
                .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, mCurrentPlayingItem.getTitle())
                .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, mCurrentPlayingItem.getDuration())
                .apply();//w  w w. j  a v a 2s . c  o  m
        //.putBitmap(RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK,bitmap).apply();

        Log.d(TAG, "Setting Remote Control Meta data **** Start");
        Log.d(TAG, "Title = " + mCurrentPlayingItem.getTitle());
        Log.d(TAG, "Album = " + mCurrentPlayingItem.getAlbum());
        Log.d(TAG, "Artist = " + mCurrentPlayingItem.getArtist());
        Log.d(TAG, "Duration = " + mCurrentPlayingItem.getDuration());
        //Log.d(TAG, "Bitmap = " + bitmap);
        Log.d(TAG, "Setting Remote Control Meta data **** End");
    }
}

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  va2 s .  com
    //Set cover too?

    localRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

    LOG.debug("Focus: updated meta-data");
}

From source file:br.com.viniciuscr.notification2android.mediaPlayer.MediaPlaybackService.java

/**
 * Notify the change-receivers that something has changed.
 * The intent that is sent contains the following data
 * for the currently playing track:/*w w w  .  j  av  a 2s .c om*/
 * "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.android.music.metachanged"
 * "com.android.music.queuechanged",
 * "com.android.music.playbackcomplete"
 * "com.android.music.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).
 */
private 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", isPlaying());
    sendStickyBroadcast(i);

    if (what.equals(PLAYSTATE_CHANGED)) {
        mRemoteControlClient.setPlaybackState(
                isPlaying() ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
    } else if (what.equals(META_CHANGED)) {
        RemoteControlClient.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 = MusicUtils.getArtwork(this, getAudioId(), getAlbumId(), false);
        if (b != null) {
            ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b);
        }
        ed.apply();
    }

    if (what.equals(QUEUE_CHANGED)) {
        saveQueue(true);
    } else {
        saveQueue(false);
    }

    // Share this notification directly with our widgets
    mAppWidgetProvider.notifyChange(this, what);
}