[Android] Move Media flags to MediaWrapper class

Thomas Guillem git at videolan.org
Fri Jul 10 20:36:53 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jul 10 20:36:34 2015 +0200| [49ffe3095388505f5eb282535e0eb89ef6ec2cc3] | committer: Thomas Guillem

Move Media flags to MediaWrapper class

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

 vlc-android/src/org/videolan/vlc/MediaWrapper.java         |    5 +++++
 .../src/org/videolan/vlc/gui/audio/AudioPlayer.java        |    3 +--
 .../org/videolan/vlc/gui/browser/BaseBrowserAdapter.java   |    4 +---
 .../org/videolan/vlc/gui/browser/BaseBrowserFragment.java  |    5 ++---
 .../src/org/videolan/vlc/gui/video/VideoGridFragment.java  |    5 ++---
 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java    |    9 ++++-----
 vlc-android/src/org/videolan/vlc/util/VLCOptions.java      |   12 ++++--------
 7 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaWrapper.java b/vlc-android/src/org/videolan/vlc/MediaWrapper.java
index 5e8401c..d9a05c7 100644
--- a/vlc-android/src/org/videolan/vlc/MediaWrapper.java
+++ b/vlc-android/src/org/videolan/vlc/MediaWrapper.java
@@ -48,6 +48,11 @@ public class MediaWrapper implements Parcelable {
     public final static int TYPE_SUBTITLE = 4;
     public final static int TYPE_PLAYLIST = 5;
 
+    public final static int MEDIA_VIDEO = 0x01;
+    public final static int MEDIA_NO_HWACCEL = 0x02;
+    public final static int MEDIA_PAUSED = 0x4;
+    public final static int MEDIA_FORCE_AUDIO = 0x8;
+
     protected String mTitle;
     private String mArtist;
     private String mGenre;
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index b9b2007..3499c30 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -64,7 +64,6 @@ import org.videolan.vlc.gui.dialogs.AdvOptionsDialog;
 import org.videolan.vlc.gui.dialogs.SavePlaylistDialog;
 import org.videolan.vlc.util.Strings;
 import org.videolan.vlc.util.Util;
-import org.videolan.vlc.util.VLCOptions;
 import org.videolan.vlc.widget.AudioMediaSwitcher.AudioMediaSwitcherListener;
 
 import java.util.ArrayList;
@@ -425,7 +424,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
                 mSwitchedToVideo = false;
                 break;
             case MediaPlayer.Event.ESAdded:
-                final boolean forceAudio = (mService.getCurrentMediaWrapper().getFlags() & VLCOptions.MEDIA_FORCE_AUDIO) != 0;
+                final boolean forceAudio = (mService.getCurrentMediaWrapper().getFlags() & MediaWrapper.MEDIA_FORCE_AUDIO) != 0;
                 if (!forceAudio && !mSwitchedToVideo && event.getEsChangedType() == Media.Track.Type.Video) {
                     mService.switchToVideo();
                     mSwitchedToVideo = true;
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index 1847bf3..ca7fb9f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -39,9 +39,7 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.audio.MediaComparators;
 import org.videolan.vlc.util.CustomDirectories;
-import org.videolan.vlc.util.Strings;
 import org.videolan.vlc.util.Util;
-import org.videolan.vlc.util.VLCOptions;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -117,7 +115,7 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
             @Override
             public void onClick(View v) {
                 MediaWrapper mw = (MediaWrapper) getItem(holder.getAdapterPosition());
-                mw.removeFlags(VLCOptions.MEDIA_FORCE_AUDIO);
+                mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
 
                 if (mw.getType() == MediaWrapper.TYPE_DIR)
                     fragment.browse(mw, holder.getAdapterPosition(), true);
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index e6cffc8..9664afb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -59,7 +59,6 @@ import org.videolan.vlc.gui.video.VideoPlayerActivity;
 import org.videolan.vlc.interfaces.IRefreshable;
 import org.videolan.vlc.util.Util;
 import org.videolan.vlc.util.VLCInstance;
-import org.videolan.vlc.util.VLCOptions;
 import org.videolan.vlc.util.VLCRunnable;
 import org.videolan.vlc.util.WeakHandler;
 import org.videolan.vlc.widget.ContextMenuRecyclerView;
@@ -420,7 +419,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
         MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
         switch (id){
             case R.id.directory_view_play:
-                mw.removeFlags(VLCOptions.MEDIA_FORCE_AUDIO);
+                mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                 Util.openMedia(getActivity(), mw);
                 return true;
             case R.id.directory_view_append: {
@@ -447,7 +446,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
                 return true;
             case R.id.directory_view_play_audio: {
                 if (mService != null) {
-                    mw.addFlags(VLCOptions.MEDIA_FORCE_AUDIO);
+                    mw.addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                     mService.load(mw);
                 }
                 return true;
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 e11a515..91886b5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -71,7 +71,6 @@ import org.videolan.vlc.interfaces.IVideoBrowser;
 import org.videolan.vlc.util.AndroidDevices;
 import org.videolan.vlc.util.Util;
 import org.videolan.vlc.util.VLCInstance;
-import org.videolan.vlc.util.VLCOptions;
 import org.videolan.vlc.util.WeakHandler;
 import org.videolan.vlc.widget.SwipeRefreshLayout;
 
@@ -298,13 +297,13 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
     }
 
     protected void playVideo(MediaWrapper media, boolean fromStart) {
-        media.removeFlags(VLCOptions.MEDIA_FORCE_AUDIO);
+        media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
         VideoPlayerActivity.start(getActivity(), media.getUri(), fromStart);
     }
 
     protected void playAudio(MediaWrapper media) {
         if (mService != null) {
-            media.addFlags(VLCOptions.MEDIA_FORCE_AUDIO);
+            media.addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
             mService.load(media);
         }
     }
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 7dcb62e..6673a4b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -112,7 +112,6 @@ import org.videolan.vlc.util.AndroidDevices;
 import org.videolan.vlc.util.Strings;
 import org.videolan.vlc.util.Util;
 import org.videolan.vlc.util.VLCInstance;
-import org.videolan.vlc.util.VLCOptions;
 import org.videolan.vlc.widget.OnRepeatListener;
 
 import java.io.ByteArrayInputStream;
@@ -2595,11 +2594,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 mService.stop();
                 final MediaWrapper mw = new MediaWrapper(mUri);
                 if (wasPaused)
-                    mw.addFlags(VLCOptions.MEDIA_PAUSED);
+                    mw.addFlags(MediaWrapper.MEDIA_PAUSED);
                 if (mHardwareAccelerationError)
-                    mw.addFlags(VLCOptions.MEDIA_NO_HWACCEL);
-                mw.removeFlags(VLCOptions.MEDIA_FORCE_AUDIO);
-                mw.addFlags(VLCOptions.MEDIA_VIDEO);
+                    mw.addFlags(MediaWrapper.MEDIA_NO_HWACCEL);
+                mw.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
+                mw.addFlags(MediaWrapper.MEDIA_VIDEO);
                 mService.addCallback(this);
                 mService.load(mw);
                 savedIndexPosition = mService.getCurrentMediaPosition();
diff --git a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
index 50d1394..70afae7 100644
--- a/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
+++ b/vlc-android/src/org/videolan/vlc/util/VLCOptions.java
@@ -31,6 +31,7 @@ import org.videolan.libvlc.MediaPlayer;
 import org.videolan.libvlc.util.VLCUtil;
 import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.libvlc.util.HWDecoderUtil;
+import org.videolan.vlc.MediaWrapper;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 
@@ -49,11 +50,6 @@ public class VLCOptions {
     public static final int HW_ACCELERATION_DECODING = 1;
     public static final int HW_ACCELERATION_FULL = 2;
 
-    public final static int MEDIA_VIDEO = 0x01;
-    public final static int MEDIA_NO_HWACCEL = 0x02;
-    public final static int MEDIA_PAUSED = 0x4;
-    public final static int MEDIA_FORCE_AUDIO = 0x8;
-
     public static ArrayList<String> getLibOptions(Context context) {
         final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
 
@@ -141,9 +137,9 @@ public class VLCOptions {
     }
 
     public static void setMediaOptions(Media media, Context context, int flags) {
-        boolean noHardwareAcceleration = (flags & MEDIA_NO_HWACCEL) != 0;
-        boolean noVideo = (flags & MEDIA_VIDEO) == 0;
-        final boolean paused = (flags & MEDIA_PAUSED) != 0;
+        boolean noHardwareAcceleration = (flags & MediaWrapper.MEDIA_NO_HWACCEL) != 0;
+        boolean noVideo = (flags & MediaWrapper.MEDIA_VIDEO) == 0;
+        final boolean paused = (flags & MediaWrapper.MEDIA_PAUSED) != 0;
         int hardwareAcceleration = HW_ACCELERATION_DISABLED;
 
         if (!noHardwareAcceleration) {



More information about the Android mailing list