[Android] Video player: simplify callbacks subscription

Geoffrey Métais git at videolan.org
Mon Feb 18 18:15:48 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 18 18:14:05 2019 +0100| [10c1051b58758837a8aaf7e65d6e5c970987db4b] | committer: Geoffrey Métais

Video player: simplify callbacks subscription

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

 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 5 ++---
 1 file changed, 2 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 6be831503..d61f1d1e5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -764,8 +764,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
 
         mPlaybackStarted = false;
 
-        mService.removeCallback(this);
-
         mHandler.removeCallbacksAndMessages(null);
         mService.getMediaplayer().detachViews();
         if (mService.hasMedia() && mSwitchingView) {
@@ -2532,7 +2530,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
             updateSeekable(mService.isSeekable());
             updatePausable(mService.isPausable());
         }
-        mService.addCallback(this);
         if (mUri != null) {
             MediaWrapper media = null;
             if (!continueplayback) {
@@ -2932,7 +2929,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
                 mHandler.sendEmptyMessage(START_PLAYBACK);
             mSwitchingView = false;
             if (mService.getVolume() > 100 && !audioBoostEnabled) mService.setVolume(100);
+            mService.addCallback(this);
         } else {
+            if (mService != null) mService.removeCallback(this);
             mService = null;
             mHandler.sendEmptyMessage(AUDIO_SERVICE_CONNECTION_FAILED);
         }



More information about the Android mailing list