[Android] VideoPlayer: listen for events for the current media

Thomas Guillem git at videolan.org
Wed Jul 1 16:10:10 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jul  1 16:06:24 2015 +0200| [c5cef5345420db2491c315734758cc9c15e27319] | committer: Thomas Guillem

VideoPlayer: listen for events for the current media

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=c5cef5345420db2491c315734758cc9c15e27319
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java       |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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 9e69d60..4c37cce 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -731,6 +731,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             time = 0;
         else
             time -= 5000; // go back 5 seconds, to compensate loading time
+        mService.removeCallback(this);
         mService.stop();
         mService.setVideoEnabled(false, false);
 
@@ -1453,6 +1454,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mHardwareAccelerationError = true;
         if (mSwitchingView)
             return;
+        mService.removeCallback(this);
         mService.stop();
         mAlertDialog = new AlertDialog.Builder(VideoPlayerActivity.this)
         .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@@ -2609,10 +2611,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                     mw.addFlags(VLCOptions.MEDIA_PAUSED);
                 if (mHardwareAccelerationError)
                     mw.addFlags(VLCOptions.MEDIA_NO_HWACCEL);
+                mService.addCallback(this);
                 mService.load(mw);
                 savedIndexPosition = mService.getCurrentMediaPosition();
                 seek(intentPosition, mediaLength);
             } else {
+                mService.addCallback(this);
                 // AudioService-transitioned playback for item after sleep and resume
                 if(!mService.isPlaying())
                     mService.playIndex(savedIndexPosition);
@@ -2937,7 +2941,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     public void onConnected(PlaybackService service) {
         mService = service;
         mHandler.sendEmptyMessage(START_PLAYBACK);
-        mService.addCallback(this);
     }
 
     @Override



More information about the Android mailing list