[Android] Option to save audio delay per video

Geoffrey Métais git at videolan.org
Fri Jan 20 14:54:41 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jan 20 14:53:47 2017 +0100| [4be8f07f010794ea463b62ab6e578756f84320ed] | committer: Geoffrey Métais

Option to save audio delay per video

> https://code.videolan.org/videolan/vlc-android/commit/4be8f07f010794ea463b62ab6e578756f84320ed
---

 vlc-android/res/values/strings.xml                    |  2 ++
 vlc-android/res/xml/preferences_video.xml             | 15 ++++++++++-----
 vlc-android/src/org/videolan/vlc/PlaybackService.java |  7 ++++++-
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index af37aa8..2755d6c 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -290,6 +290,8 @@
     <string name="force_play_all_title">Video playlist mode</string>
     <string name="save_brightness_summary">Remember brightness level in video player</string>
     <string name="save_brightness_title">Save brightness level for video</string>
+    <string name="save_audiodelay_summary">Save individual audio delay for each video</string>
+    <string name="save_audiodelay_title">Save audio delay</string>
     <string name="enable_brightness_gesture_title">Brightness gesture</string>
     <string name="enable_brightness_gesture_summary">Control brightness by gesture during video playback</string>
     <string name="enable_volume_gesture_title">Volume gesture</string>
diff --git a/vlc-android/res/xml/preferences_video.xml b/vlc-android/res/xml/preferences_video.xml
index 1c5e341..389955d 100644
--- a/vlc-android/res/xml/preferences_video.xml
+++ b/vlc-android/res/xml/preferences_video.xml
@@ -18,6 +18,16 @@
         android:key="force_list_portrait"
         android:summary="@string/force_list_portrait_summary"
         android:title="@string/force_list_portrait" />
+    <CheckBoxPreference
+        android:defaultValue="false"
+        android:key="save_brightness"
+        android:summary="@string/save_brightness_summary"
+        android:title="@string/save_brightness_title" />
+    <CheckBoxPreference
+        android:defaultValue="false"
+        android:key="save_individual_audio_delay"
+        android:summary="@string/save_audiodelay_summary"
+        android:title="@string/save_audiodelay_title" />
 
     <PreferenceCategory android:title="@string/controls_prefs_category">
         <CheckBoxPreference
@@ -26,11 +36,6 @@
             android:summary="@string/force_play_all_summary"
             android:title="@string/force_play_all_title" />
         <CheckBoxPreference
-            android:defaultValue="false"
-            android:key="save_brightness"
-            android:summary="@string/save_brightness_summary"
-            android:title="@string/save_brightness_title" />
-        <CheckBoxPreference
             android:defaultValue="true"
             android:key="enable_volume_gesture"
             android:summary="@string/enable_volume_gesture_summary"
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index d271700..e83c71d 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -579,6 +579,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
         public void onEvent(MediaPlayer.Event event) {
             switch (event.type) {
                 case MediaPlayer.Event.Playing:
+                    loadMediaMeta();
                     if(mSavedTime != 0L)
                         seek(mSavedTime);
                     mSavedTime = 0L;
@@ -680,6 +681,9 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                 progress = 0f;
             media.setTime(progress == 0f ? 0L : time);
             media.setLongMeta(mMedialibrary, MediaWrapper.META_PROGRESS, (long) (progress*100));
+            //Save audio delay
+            if (mSettings.getBoolean("save_individual_audio_delay", false))
+                media.setLongMeta(mMedialibrary, MediaWrapper.META_AUDIODELAY, mMediaPlayer.getAudioDelay());
         }
     }
 
@@ -687,7 +691,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
         MediaWrapper media = mMedialibrary.findMedia(getCurrentMediaWrapper());
         if (media == null || media.getId() == 0)
             return;
-        mMediaPlayer.setAudioDelay(media.getMetaLong(mMedialibrary, MediaWrapper.META_AUDIODELAY));
+        if (mSettings.getBoolean("save_individual_audio_delay", false))
+                mMediaPlayer.setAudioDelay(media.getMetaLong(mMedialibrary, MediaWrapper.META_AUDIODELAY));
     }
 
     private final MediaWrapperList.EventListener mListEventListener = new MediaWrapperList.EventListener() {



More information about the Android mailing list