[Android] Force audio flag when switching to audio playback

Geoffrey Métais git at videolan.org
Wed Nov 16 15:54:24 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 16 15:36:02 2016 +0100| [d498891919104eae6bde84e4b688e89a62d49c9a] | committer: Geoffrey Métais

Force audio flag when switching to audio playback

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

 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java        | 3 ++-
 .../org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java   | 3 ++-
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java        | 7 ++++---
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index b30a492..de32a66 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -308,8 +308,9 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
 
         if (mService.hasMedia() && !mService.isVideoPlaying()) {
             SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(getActivity());
-            if (isResumed() && mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)) {
+            if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)) {
                 mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false).apply();
+                mService.getCurrentMediaWrapper().removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                 mService.switchToVideo();
                 return;
             } else
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
index 070afe1..0683429 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
@@ -153,8 +153,9 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
         mPlayPauseButton.setImageResource(mService.isPlaying() ? R.drawable.ic_pause_w : R.drawable.ic_play_w);
         if (mService.hasMedia()) {
             SharedPreferences mSettings= PreferenceManager.getDefaultSharedPreferences(this);
-            if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){
+            if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)) {
                 mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false).apply();
+                mService.getCurrentMediaWrapper().removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                 mService.switchToVideo();
                 finish();
                 return;
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 3b83322..ac1b70a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -899,16 +899,17 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         vlcVout.removeCallback(this);
         vlcVout.detachViews();
 
-        if(mSwitchingView && mService != null) {
+        if (mSwitchingView && mService != null) {
             Log.d(TAG, "mLocation = \"" + mUri + "\"");
             if (mSwitchToPopup)
                 mService.switchToPopup(mService.getCurrentMediaPosition());
-            else
+            else {
+                mService.getCurrentMediaWrapper().addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                 mService.showWithoutParse(mService.getCurrentMediaPosition());
+            }
             return;
         }
 
-
         cleanUI();
 
         if (mService.isSeekable()) {



More information about the Android mailing list