[Android] Repeat video with long press on play/pause

Geoffrey Métais git at videolan.org
Wed Aug 5 11:27:21 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Aug  5 11:26:45 2015 +0200| [dcb8dc3c0e4c0456b86f65f7d1630ccaa66164cd] | committer: Geoffrey Métais

Repeat video with long press on play/pause

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

 .../vlc/gui/video/VideoPlayerActivity.java         |   22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)

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 bfd689d..6fd8466 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -519,6 +519,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mSeekbar.setOnSeekBarChangeListener(mSeekListener);
         mLock.setOnClickListener(mLockListener);
         mPlayPause.setOnClickListener(mPlayPauseListener);
+        mPlayPause.setOnLongClickListener(mPlayPauseLongListener);
         mLength.setOnClickListener(mRemainingTimeListener);
         mTime.setOnClickListener(mRemainingTimeListener);
         mSize.setOnClickListener(mSizeListener);
@@ -534,6 +535,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mSeekbar.setOnSeekBarChangeListener(null);
         mLock.setOnClickListener(null);
         mPlayPause.setOnClickListener(null);
+        mPlayPause.setOnLongClickListener(null);
         mLength.setOnClickListener(null);
         mTime.setOnClickListener(null);
         mSize.setOnClickListener(null);
@@ -1413,6 +1415,10 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     private void endReached() {
         if (mService == null)
             return;
+        if (mService.getRepeatType() == PlaybackService.RepeatType.Once){
+            seek(0);
+            return;
+        }
         if(mService.expand() == 0) {
             startLoading();
             Log.d(TAG, "Found a video playlist, expanding it");
@@ -2041,6 +2047,22 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         }
     };
 
+    private final View.OnLongClickListener mPlayPauseLongListener = new View.OnLongClickListener() {
+        @Override
+        public boolean onLongClick(View v) {
+            if (mService == null)
+                return false;
+            if (mService.getRepeatType() == PlaybackService.RepeatType.Once) {
+                showInfo("repeat off");
+                mService.setRepeatType(PlaybackService.RepeatType.None);
+            } else {
+                mService.setRepeatType(PlaybackService.RepeatType.Once);
+                showInfo("repeat video");
+            }
+            return true;
+        }
+    };
+
     private final void doPlayPause() {
         if (mService.isPlaying()) {
             pause();



More information about the Android mailing list