Example usage for android.media MediaMetadataRetriever METADATA_KEY_TITLE

List of usage examples for android.media MediaMetadataRetriever METADATA_KEY_TITLE

Introduction

In this page you can find the example usage for android.media MediaMetadataRetriever METADATA_KEY_TITLE.

Prototype

int METADATA_KEY_TITLE

To view the source code for android.media MediaMetadataRetriever METADATA_KEY_TITLE.

Click Source Link

Document

The metadata key to retrieve the data source title.

Usage

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();/*  w  ww. j a v a  2 s.c o  m*/
    //Set cover too?

    localRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

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

From source file:com.xperia64.timidityae.MusicService.java

@SuppressLint("NewApi")
public void play() {
    if (playList != null && currSongNumber >= 0) {
        shouldAdvance = false;/*  w  w  w .ja  v a  2s.co  m*/
        death = true;
        fullStop = false;
        stop();
        death = false;
        Globals.shouldRestore = true;
        while (!death && ((Globals.isPlaying == 0 || JNIHandler.alternativeCheck == 333333))) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        if (!death) {
            MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            String tmpTitle;
            Globals.currArt = null;
            final int songIndex;
            if (shuffleMode == 1) {
                songIndex = realSongNumber = shuffledIndices.get(currSongNumber);
            } else {
                songIndex = realSongNumber = currSongNumber;
            }
            try {
                mmr.setDataSource(playList.get(songIndex));
                tmpTitle = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
                if (tmpTitle != null) {
                    if (TextUtils.isEmpty(tmpTitle))
                        tmpTitle = playList.get(songIndex)
                                .substring(playList.get(songIndex).lastIndexOf('/') + 1);
                } else {
                    tmpTitle = playList.get(songIndex).substring(playList.get(songIndex).lastIndexOf('/') + 1);
                }

            } catch (RuntimeException e) {
                tmpTitle = playList.get(songIndex).substring(playList.get(songIndex).lastIndexOf('/') + 1);
            }
            boolean goodart = false;
            if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) // Please work
            {
                try {

                    byte[] art = mmr.getEmbeddedPicture();
                    if (art != null) {
                        Globals.currArt = BitmapFactory.decodeByteArray(art, 0, art.length);
                        goodart = Globals.currArt != null;
                    }
                } catch (Exception e) {
                }
            }
            if (!goodart) {
                String goodPath = playList.get(songIndex).substring(0,
                        playList.get(songIndex).lastIndexOf('/') + 1) + "folder.jpg";
                if (new File(goodPath).exists()) {
                    try {
                        Globals.currArt = BitmapFactory.decodeFile(goodPath);
                    } catch (RuntimeException e) {
                    }
                } else {
                    // Try albumart.jpg
                    goodPath = playList.get(songIndex).substring(0,
                            playList.get(songIndex).lastIndexOf('/') + 1) + "AlbumArt.jpg";
                    if (new File(goodPath).exists()) {
                        try {
                            Globals.currArt = BitmapFactory.decodeFile(goodPath);
                        } catch (RuntimeException e) {
                            // 
                        }
                    }
                }
            }
            if (shouldDoWidget) {
                Intent intent = new Intent(this, TimidityAEWidgetProvider.class);
                intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
                // Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID,
                // since it seems the onUpdate() is only fired on that:
                ids = AppWidgetManager.getInstance(getApplication())
                        .getAppWidgetIds(new ComponentName(getApplication(), TimidityAEWidgetProvider.class));

                //intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                intent.putExtra("com.xperia64.timidityae.timidityaewidgetprovider.onlyart", true);
                sendBroadcast(intent);
            }
            Intent new_intent = new Intent();
            new_intent.setAction(getResources().getString(R.string.ta_rec));
            new_intent.putExtra(getResources().getString(R.string.ta_cmd), 6);
            sendBroadcast(new_intent);

            currTitle = tmpTitle;
            shouldAdvance = true;
            paused = false;

            final int x = JNIHandler.play(playList.get(songIndex));
            if (x != 0) {
                switch (x) {
                case -1:
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(getApplicationContext(), getResources().getString(R.string.srv_fnf),
                                    Toast.LENGTH_SHORT).show();
                        }
                    });

                    break;
                case -3:
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(getApplicationContext(),
                                    "Error initializing AudioTrack. Try decreasing the buffer size.",
                                    Toast.LENGTH_LONG).show();
                        }
                    });

                    break;
                case -9:
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(getApplicationContext(),
                                    getResources().getString(R.string.srv_loading), Toast.LENGTH_SHORT).show();
                        }
                    });
                    break;
                default:
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(getApplicationContext(),
                                    String.format(getResources().getString(R.string.srv_unk), x),
                                    Toast.LENGTH_SHORT).show();
                        }
                    });
                    break;
                }

                Globals.isPlaying = 1;
                JNIHandler.type = true;
                shouldAdvance = false;
                JNIHandler.paused = false;
                stop();
            } else {
                updateNotification(currTitle, paused);
                new Thread(new Runnable() {
                    public void run() {
                        while (!death && ((Globals.isPlaying == 1 && shouldAdvance))) {
                            if (JNIHandler.alternativeCheck == 555555)
                                death = true;

                            //System.out.println(String.format("alt check: %d death: %s isplaying: %d shouldAdvance: %s seekBarReady: %s",JNIHandler.alternativeCheck,death?"true":"false",Globals.isPlaying,shouldAdvance?"true":"false",JNIHandler.seekbarReady?"true":"false"));
                            try {
                                Thread.sleep(10);
                            } catch (InterruptedException e) {
                            }
                        }
                        if (!death) {
                            Intent new_intent = new Intent();
                            new_intent.setAction(getResources().getString(R.string.ta_rec));
                            new_intent.putExtra(getResources().getString(R.string.ta_cmd), 0);
                            new_intent.putExtra(getResources().getString(R.string.ta_startt),
                                    JNIHandler.maxTime);
                            new_intent.putExtra(getResources().getString(R.string.ta_songttl), currTitle);
                            new_intent.putExtra(getResources().getString(R.string.ta_filename),
                                    playList.get(songIndex));
                            new_intent.putExtra("stupidNumber", songIndex);
                            sendBroadcast(new_intent);
                        }
                        if (new File(playList.get(songIndex) + ".def.tcf").exists()
                                || new File(playList.get(songIndex) + ".def.tzf").exists()) {
                            String suffix;
                            if (new File(playList.get(songIndex) + ".def.tcf").exists()
                                    && new File(playList.get(songIndex) + ".def.tzf").exists()) {
                                suffix = (Globals.compressCfg ? ".def.tzf" : ".def.tcf");
                            } else if (new File(playList.get(songIndex) + ".def.tcf").exists()) {
                                suffix = ".def.tcf";
                            } else {
                                suffix = ".def.tzf";
                            }
                            JNIHandler.shouldPlayNow = false;
                            JNIHandler.currTime = 0;
                            while (Globals.isPlaying == 0 && !death && shouldAdvance
                                    && !JNIHandler.dataWritten) {
                                try {
                                    Thread.sleep(25);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }
                            Intent new_intent = new Intent(); // silly, but should be done async. I think.
                            new_intent.setAction(getResources().getString(R.string.msrv_rec));
                            new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 17);
                            new_intent.putExtra(getResources().getString(R.string.msrv_infile),
                                    playList.get(songIndex) + suffix);
                            new_intent.putExtra(getResources().getString(R.string.msrv_reset), true);
                            sendBroadcast(new_intent);
                        }
                        while (!death && (((Globals.isPlaying == 0 || JNIHandler.alternativeCheck == 333333)
                                && shouldAdvance))) {
                            try {
                                Thread.sleep(25);
                            } catch (InterruptedException e) {
                            }
                        }
                        if (shouldAdvance && !death) {
                            shouldAdvance = false;
                            new Thread(new Runnable() {
                                public void run() {
                                    if (playList.size() > 1
                                            && (((songIndex + 1 < playList.size() && loopMode == 0))
                                                    || loopMode == 1)) {
                                        next();
                                    } else if (loopMode == 2 || playList.size() == 1) {
                                        play();
                                    } else if (loopMode == 0) {
                                        Globals.hardStop = true;
                                        Intent new_intent = new Intent();
                                        new_intent.setAction(getResources().getString(R.string.ta_rec));
                                        new_intent.putExtra(getResources().getString(R.string.ta_cmd), 5);
                                        new_intent.putExtra(getResources().getString(R.string.ta_pause), false);
                                        sendBroadcast(new_intent);
                                    }
                                }
                            }).start();

                        }

                    }
                }).start();
            }
        }
    }
}

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:/* ww  w.  ja v a 2 s . co m*/
 * "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);
}

From source file:org.videolan.vlc.audio.AudioService.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
    if (!LibVlcUtil.isICSOrLater()) // NOP check
        return;//from w w  w  .  j  a  va2 s  .  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_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.vlc2.audio.AudioService.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
    if (!LibVlcUtil.isICSOrLater()) // NOP check
        return;//  w w  w  . jav a2  s .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:com.dzt.musicplay.player.AudioService.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClientMetadata() {
    if (!LibVlcUtil.isICSOrLater()) // NOP check
        return;/* ww w.  jav a2s . 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_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:com.andrew.apolloMod.service.ApolloService.java

/**
 * 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).// w  ww  .ja  v a2s  .c o  m
 */
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 (Constants.isApi14Supported()) {
        if (what.equals(PLAYSTATE_CHANGED)) {
            mRemoteControlClient.setPlaybackState(mIsSupposedToBePlaying ? 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 = 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);

}

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  w w.  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();//ww w.  j  av  a2  s .co m
        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:com.adityarathi.muo.services.AudioPlaybackService.java

/**
 * Updates all remote control clients (including the lockscreen controls).
 */// w w  w  .  j a  v a 2 s. c  o m
public void updateRemoteControlClients(SongHelper songHelper) {
    try {
        //Update the remote controls

        mRemoteControlClientCompat.editMetadata(true)
                .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getCurrentSong().getArtist())
                .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getCurrentSong().getTitle())
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getCurrentSong().getAlbum())
                .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, getCurrentMediaPlayer().getDuration())
                .putBitmap(RemoteControlClientCompat.MetadataEditorCompat.METADATA_KEY_ARTWORK,
                        getCurrentSong().getAlbumArt())

                .apply();

        if (mRemoteControlClientCompat != null) {

            if (getCurrentMediaPlayer().isPlaying())
                mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
            else
                mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);

        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}