[Android] Option to disable coverArt as lockscreen wallpaper

Geoffrey Métais git at videolan.org
Thu Feb 11 12:18:30 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 11 12:17:31 2016 +0100| [6f6c553fec3ac8ac9d14274f813f3f69e4a5e912] | committer: Geoffrey Métais

Option to disable coverArt as lockscreen wallpaper

> https://code.videolan.org/videolan/vlc-android/commit/6f6c553fec3ac8ac9d14274f813f3f69e4a5e912
---

 vlc-android/res/values/strings.xml                           |  2 ++
 vlc-android/res/xml/preferences_ui.xml                       |  5 +++++
 vlc-android/src/org/videolan/vlc/PlaybackService.java        | 12 +++++++++---
 .../org/videolan/vlc/gui/tv/preferences/PreferencesUi.java   |  2 +-
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 1660bc1..3a88ec3 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -375,6 +375,8 @@
     <string name="player_touch_disable_all">Disable all Touch controls</string>
     <string name="tv_ui_title">Android TV interface</string>
     <string name="tv_ui_summary">Change UI to TV adapted theme</string>
+    <string name="lockscreen_cover_title">Media cover on Lockscreen</string>
+    <string name="lockscreen_cover_summary">When available, set the current media cover art as lockscreen wallpaper</string>
 
     <!--Accessibility-->
     <string name="more_actions">More Actions</string>
diff --git a/vlc-android/res/xml/preferences_ui.xml b/vlc-android/res/xml/preferences_ui.xml
index f20b755..d255d75 100644
--- a/vlc-android/res/xml/preferences_ui.xml
+++ b/vlc-android/res/xml/preferences_ui.xml
@@ -29,6 +29,11 @@
             android:entries="@array/touch_entries"
             android:entryValues="@array/touch_values"/>
         <CheckBoxPreference
+            android:defaultValue="true"
+            android:key="lockscreen_cover"
+            android:summary="@string/lockscreen_cover_summary"
+            android:title="@string/lockscreen_cover_title" />
+        <CheckBoxPreference
             android:defaultValue="false"
             android:key="dialog_confirm_resume"
             android:summary="@string/confirm_resume_summary"
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 1d2528b..72ad267 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -839,11 +839,14 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         if (mMediaPlayer.getVLCVout().areViewsAttached())
             return;
         try {
+            boolean coverOnLockscreen = mSettings.getBoolean("lockscreen_cover", true);
             MediaMetadataCompat metaData = mMediaSession.getController().getMetadata();
             String title = metaData.getString(MediaMetadataCompat.METADATA_KEY_TITLE);
             String artist = metaData.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST);
             String album = metaData.getString(MediaMetadataCompat.METADATA_KEY_ALBUM);
-            Bitmap cover = metaData.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART);
+            Bitmap cover = coverOnLockscreen ?
+                    metaData.getBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART) :
+                    AudioUtil.getCover(this, getCurrentMedia(), 512);
             if (cover == null)
                 cover = BitmapFactory.decodeResource(VLCApplication.getAppContext().getResources(), R.drawable.icon);
             Notification notification;
@@ -1118,7 +1121,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         String title = media.getNowPlaying();
         if (title == null)
             title = media.getTitle();
-        Bitmap cover = AudioUtil.getCover(this, media, 512);
+        boolean coverOnLockscreen = mSettings.getBoolean("lockscreen_cover", true);
         MediaMetadataCompat.Builder bob = new MediaMetadataCompat.Builder();
         bob.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
             .putString(MediaMetadataCompat.METADATA_KEY_GENRE, MediaUtils.getMediaGenre(this, media))
@@ -1126,8 +1129,11 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                 .putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, MediaUtils.getMediaReferenceArtist(this, media))
                 .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, MediaUtils.getMediaAlbum(this, media))
                 .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, media.getLength());
-        if (cover != null && cover.getConfig() != null) //In case of format not supported
+        if (coverOnLockscreen) {
+            Bitmap cover = AudioUtil.getCover(this, media, 512);
+            if (cover != null && cover.getConfig() != null) //In case of format not supported
                 bob.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, cover.copy(cover.getConfig(), false));
+        }
         mMediaSession.setMetadata(bob.build());
 
         //Send metadata to Pebble watch
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
index 803ddc1..cb88a4a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesUi.java
@@ -29,7 +29,6 @@ import android.os.Bundle;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.TwoStatePreference;
 
-import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.vlc.PlaybackService;
 import org.videolan.vlc.R;
 import org.videolan.vlc.util.AndroidDevices;
@@ -59,6 +58,7 @@ public class PreferencesUi extends BasePreferenceFragment {
         findPreference("enable_steal_remote_control").setVisible(false);
         findPreference(KEY_ENABLE_TOUCH_PLAYER).setVisible(AndroidDevices.hasTsp());
         findPreference("tv_ui").setVisible(AndroidDevices.hasTsp());
+        findPreference("lockscreen_cover").setVisible(false);
     }
 
     @Override



More information about the Android mailing list