[Android] Save same playback rate for video and audio
Geoffrey Métais
git at videolan.org
Wed Dec 20 17:10:04 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Dec 14 15:05:21 2017 +0100| [c8da4cfe7e5cd5d66d3efdc7b8658710cc1c353d] | committer: Geoffrey Métais
Save same playback rate for video and audio
Close #445
(cherry picked from commit 95c071efbbc3d60abe9a777ab83815794d217e08)
> https://code.videolan.org/videolan/vlc-android/commit/c8da4cfe7e5cd5d66d3efdc7b8658710cc1c353d
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 8 ++++----
.../src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java | 7 +++----
.../src/org/videolan/vlc/gui/preferences/PreferencesActivity.java | 4 ++--
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 6 ------
4 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index dbe63d116..e79063192 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -2098,8 +2098,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
mMediaPlayer.setVideoTitleDisplay(MediaPlayer.Position.Disable, 0);
changeAudioFocus(true);
mMediaPlayer.setEventListener(mMediaPlayerListener);
- if (!isVideoPlaying && mMediaPlayer.getRate() == 1.0F && mSettings.getBoolean(PreferencesActivity.KEY_AUDIO_PLAYBACK_SPEED_PERSIST, true))
- setRate(mSettings.getFloat(PreferencesActivity.KEY_AUDIO_PLAYBACK_RATE, 1.0F), true);
+ if (mMediaPlayer.getRate() == 1.0F && mSettings.getBoolean(PreferencesActivity.KEY_PLAYBACK_SPEED_PERSIST, true))
+ setRate(mSettings.getFloat(PreferencesActivity.KEY_PLAYBACK_RATE, 1.0F), false);
if (mSavedTime <= 0L && mw.getTime() >= 0L && mw.isPodcast())
mSavedTime = mw.getTime();
mMediaPlayer.play();
@@ -2387,8 +2387,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@MainThread
public void setRate(float rate, boolean save) {
mMediaPlayer.setRate(rate);
- if (save && mSettings.getBoolean(PreferencesActivity.KEY_AUDIO_PLAYBACK_SPEED_PERSIST, true))
- mSettings.edit().putFloat(PreferencesActivity.KEY_AUDIO_PLAYBACK_RATE, rate).apply();
+ if (save && mSettings.getBoolean(PreferencesActivity.KEY_PLAYBACK_SPEED_PERSIST, true))
+ mSettings.edit().putFloat(PreferencesActivity.KEY_PLAYBACK_RATE, rate).apply();
}
@MainThread
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
index d149710c1..e70337acc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/PlaybackSpeedDialog.java
@@ -37,7 +37,6 @@ import org.videolan.vlc.R;
import org.videolan.vlc.gui.PlaybackServiceFragment;
import org.videolan.vlc.gui.helpers.OnRepeatListener;
import org.videolan.vlc.gui.helpers.UiTools;
-import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.util.Strings;
public class PlaybackSpeedDialog extends DialogFragment implements PlaybackService.Client.Callback {
@@ -104,7 +103,7 @@ public class PlaybackSpeedDialog extends DialogFragment implements PlaybackServi
return;
if (fromUser) {
float rate = (float) Math.pow(4, ((double) progress / (double) 100) - 1);
- mService.setRate(rate, mService.getCurrentMediaWrapper().getType() == MediaWrapper.TYPE_AUDIO);
+ mService.setRate(rate, true);
updateInterface();
}
}
@@ -122,7 +121,7 @@ public class PlaybackSpeedDialog extends DialogFragment implements PlaybackServi
if (mService == null || mService.getRate() == 1.0d || mService.getCurrentMediaWrapper() == null)
return;
- mService.setRate(1F, mService.getCurrentMediaWrapper().getType() == MediaWrapper.TYPE_AUDIO);
+ mService.setRate(1F, true);
setRateProgress();
}
};
@@ -156,7 +155,7 @@ public class PlaybackSpeedDialog extends DialogFragment implements PlaybackServi
float rate = Math.round((initialRate + delta) * 100f) / 100f;
if (rate < 0.25f || rate > 4f || mService.getCurrentMediaWrapper() == null)
return;
- mService.setRate(rate, mService.getCurrentMediaWrapper().getType() == MediaWrapper.TYPE_AUDIO);
+ mService.setRate(rate, true);
}
private void updateInterface() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
index b19f5f8d2..28794a3a1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesActivity.java
@@ -47,8 +47,8 @@ public class PreferencesActivity extends AppCompatActivity implements PlaybackSe
public final static String VIDEO_RATIO = "video_ratio";
public final static String AUTO_RESCAN = "auto_rescan";
public final static String LOGIN_STORE = "store_login";
- public static final String KEY_AUDIO_PLAYBACK_RATE = "playback_rate";
- public static final String KEY_AUDIO_PLAYBACK_SPEED_PERSIST = "playback_speed";
+ public static final String KEY_PLAYBACK_RATE = "playback_rate";
+ public static final String KEY_PLAYBACK_SPEED_PERSIST = "playback_speed";
public final static String KEY_VIDEO_APP_SWITCH = "video_action_switch";
public final static int RESULT_RESCAN = RESULT_FIRST_USER + 1;
public final static int RESULT_RESTART = RESULT_FIRST_USER + 2;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 1adb0ff7e..9f08167df 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -713,8 +713,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (mSavedTime != -1)
editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, mSavedTime);
- editor.putFloat(PreferencesActivity.VIDEO_RATE, mSavedRate);
-
// Save selected subtitles
String subtitleList_serialized = null;
if(mSubtitleSelectedFiles.size() > 0) {
@@ -3279,10 +3277,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
else
mService.loadUri(mUri);
- if (!resumePlaylist ||!isPlaying || positionInPlaylist != mService.getCurrentMediaPosition()) {
- final boolean ratePref = mSettings.getBoolean(PreferencesActivity.KEY_AUDIO_PLAYBACK_SPEED_PERSIST, true);
- mService.setRate(ratePref || mRateHasChanged ? mSettings.getFloat(PreferencesActivity.VIDEO_RATE, 1.0f) : 1.0F, false);
- }
// Get possible subtitles
getSubtitles();
More information about the Android
mailing list