[Android] Video Player : add option to play from start.

Alexandre Perraud git at videolan.org
Tue Nov 20 18:17:28 CET 2012


vlc-ports/android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Tue Nov 20 18:02:50 2012 +0100| [a6598cf03c3b029d955201cf8dc7b765b5495939] | committer: Jean-Baptiste Kempf

Video Player : add option to play from start.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 vlc-android/res/menu/video_list.xml                     |    3 +++
 vlc-android/res/values-fr/strings.xml                   |    1 +
 vlc-android/res/values/strings.xml                      |    1 +
 .../org/videolan/vlc/gui/video/VideoGridFragment.java   |   10 +++++++++-
 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java |   15 +++++++++++++--
 5 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/vlc-android/res/menu/video_list.xml b/vlc-android/res/menu/video_list.xml
index ffaa102..f2400f2 100644
--- a/vlc-android/res/menu/video_list.xml
+++ b/vlc-android/res/menu/video_list.xml
@@ -4,6 +4,9 @@
         android:id="@+id/video_list_play"
         android:title="@string/play" />
     <item
+        android:id="@+id/video_list_play_from_start"
+        android:title="@string/play_from_start" />
+    <item
         android:id="@+id/video_list_info"
         android:title="@string/info" />
     <item
diff --git a/vlc-android/res/values-fr/strings.xml b/vlc-android/res/values-fr/strings.xml
index 833984c..0f02d0e 100644
--- a/vlc-android/res/values-fr/strings.xml
+++ b/vlc-android/res/values-fr/strings.xml
@@ -18,6 +18,7 @@
     <string name="show_player">Afficher Lecteur</string>
     <string name="hide_mini_player">Cacher Mini-lecteur</string>
     <string name="play">Lire</string>
+    <string name="play_from_start">Lire du début</string>
     <string name="append">Lire à la suite</string>
     <string name="play_all">Lire tout</string>
     <string name="append_all">Lire tout à la suite</string>
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 69ec575..4f5ea50 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -24,6 +24,7 @@
     <string name="show_player">Show player</string>
     <string name="hide_mini_player">Hide mini-player</string>
     <string name="play">Play</string>
+    <string name="play_from_start">Play from start</string>
     <string name="play_as_audio">Play as audio</string>
     <string name="play_as_video">Play as video</string>
     <string name="append">Append</string>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 69a1af1..7f98f0a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -94,6 +94,9 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
     private ThumbnailerManager mThumbnailerManager;
     private VideoGridAnimator mAnimator;
 
+    // Play video from start or not
+    public boolean mFromStart = false;
+
     /* All subclasses of Fragment must include a public empty constructor. */
     public VideoGridFragment() { }
 
@@ -154,6 +157,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
         mMediaLibrary.addUpdateHandler(mHandler);
         updateViewMode();
         mAnimator.animate();
+        mFromStart = false;
     }
 
     @Override
@@ -239,7 +243,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
 
     protected void playVideo(int position) {
         Media item = (Media) getListAdapter().getItem(position);
-        VideoPlayerActivity.start(getActivity(), item.getLocation());
+        VideoPlayerActivity.start(getActivity(), item.getLocation(), mFromStart);
     }
 
     private boolean handleContextItemSelected(MenuItem menu, int position) {
@@ -248,6 +252,10 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
         case R.id.video_list_play:
             playVideo(position);
             return true;
+        case R.id.video_list_play_from_start:
+            mFromStart = true;
+            playVideo(position);
+            return true;
         case R.id.video_list_info:
             Intent intent = new Intent(getActivity(), MediaInfoActivity.class);
             intent.putExtra("itemLocation",
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 af1433f..5d3ea34 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -382,14 +382,23 @@ public class VideoPlayerActivity extends Activity {
     }
 
     public static void start(Context context, String location) {
-        start(context, location, null, false);
+        start(context, location, null, false, false);
+    }
+
+    public static void start(Context context, String location, Boolean fromStart) {
+        start(context, location, null, false, fromStart);
     }
 
     public static void start(Context context, String location, String title, Boolean dontParse) {
+        start(context, location, title, dontParse, false);
+    }
+
+    public static void start(Context context, String location, String title, Boolean dontParse, Boolean fromStart) {
         Intent intent = new Intent(context, VideoPlayerActivity.class);
         intent.putExtra("itemLocation", location);
         intent.putExtra("itemTitle", title);
         intent.putExtra("dontParse", dontParse);
+        intent.putExtra("fromStart", fromStart);
 
         if (dontParse)
             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
@@ -1203,6 +1212,7 @@ public class VideoPlayerActivity extends Activity {
         mLocation = null;
         String title = getResources().getString(R.string.title);
         boolean dontParse = false;
+        boolean fromStart = false;
         String itemTitle = null;
 
         if (getIntent().getAction() != null
@@ -1214,6 +1224,7 @@ public class VideoPlayerActivity extends Activity {
             mLocation = getIntent().getExtras().getString("itemLocation");
             itemTitle = getIntent().getExtras().getString("itemTitle");
             dontParse = getIntent().getExtras().getBoolean("dontParse");
+            fromStart = getIntent().getExtras().getBoolean("fromStart");
         }
 
         mSurface.setKeepScreenOn(true);
@@ -1228,7 +1239,7 @@ public class VideoPlayerActivity extends Activity {
         if (mLocation != null && mLocation.length() > 0 && !dontParse) {
             // restore last position
             Media media = DatabaseManager.getInstance(this).getMedia(this, mLocation);
-            if (media != null && media.getTime() > 0)
+            if (media != null && media.getTime() > 0 && !fromStart)
                 mLibVLC.setTime(media.getTime());
 
             try {



More information about the Android mailing list