[Android] [PATCH 5/5] Video : Mute during loading if activity has stopped
Alexandre Perraud
4leyx4ndre at gmail.com
Thu Sep 11 19:40:22 CEST 2014
Proposition to fix the audio glitch when activity has stopped.
---
.../videolan/vlc/gui/video/VideoPlayerActivity.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
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 66d2d0e..55aee82 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -545,6 +545,11 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
// Listen for changes to media routes.
mediaRouterAddCallback(true);
}
+
+ if (mHasStopped && mAudioManager != null){
+ mAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
+ Log.i(TAG, "VLC has stopped : mute video during loading");
+ }
}
/**
@@ -588,6 +593,16 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
mLibVLC.addSubtitleTrack(file);
}
}
+
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (mAudioManager != null && mHasStopped) {
+ Log.i(TAG, "VLC has stopped : unmute video");
+ mAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
+ mHasStopped = false;
+ }
+ }}, 1000);
}
@Override
@@ -1803,10 +1818,8 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
}
private void pauseIfHasStopped() {
- if (mHasStopped) {
- mHasStopped = false;
+ if (mHasStopped)
pause();
- }
}
/**
--
1.9.1
More information about the Android
mailing list