[Android] show info option only when we have META tracks
Geoffrey Métais
git at videolan.org
Wed Dec 10 10:37:06 CET 2014
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Dec 9 18:47:51 2014 +0100| [2ad3b4e8a87e0ab7b806624cd23cb1c8685747aa] | committer: Geoffrey Métais
show info option only when we have META tracks
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=2ad3b4e8a87e0ab7b806624cd23cb1c8685747aa
---
.../videolan/vlc/gui/video/MediaInfoFragment.java | 10 +++++++---
.../videolan/vlc/gui/video/VideoGridFragment.java | 21 +++++++++++++++++---
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index 98bde10..d234b14 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -28,6 +28,7 @@ import org.videolan.libvlc.Media;
import org.videolan.libvlc.TrackInfo;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
+import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.util.BitmapUtil;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.VLCInstance;
@@ -113,18 +114,19 @@ public class MediaInfoFragment extends ListFragment {
} catch (LibVlcException e) {
return;
}
+ int videoHeight = mItem.getHeight();
+ int videoWidth = mItem.getWidth();
+ if (videoWidth == 0 || videoHeight == 0)
+ return;
mTracks = mLibVlc.readTracksInfo(mItem.getLocation());
mHandler.sendEmptyMessage(NEW_TEXT);
DisplayMetrics screen = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(screen);
- int videoHeight = mItem.getHeight();
- int videoWidth = mItem.getWidth();
int width, height;
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
width = Math.min(screen.widthPixels, screen.heightPixels);
- height = width * 9 / 16;
} else {
width = screen.widthPixels /2 ;
}
@@ -164,6 +166,8 @@ public class MediaInfoFragment extends ListFragment {
if (track.Type != TrackInfo.TYPE_META)
mAdapter.add(track);
}
+ if (mAdapter.isEmpty())
+ ((MainActivity)getActivity()).popSecondaryFragment();
}
private Handler mHandler = new MediaInfoHandler(this);
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 76bb1aa..e03d71c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -26,8 +26,11 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import org.videolan.android.ui.SherlockGridFragment;
+import org.videolan.libvlc.LibVLC;
+import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
import org.videolan.libvlc.Media;
+import org.videolan.libvlc.TrackInfo;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaGroup;
import org.videolan.vlc.MediaLibrary;
@@ -97,6 +100,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
private VideoListAdapter mVideoAdapter;
private MediaLibrary mMediaLibrary;
+ private LibVLC mLibVlc;
private Thumbnailer mThumbnailer;
private VideoGridAnimator mAnimator;
private SwipeRefreshLayout mSwipeRefreshLayout;
@@ -124,6 +128,9 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
FragmentActivity activity = getActivity();
if (activity != null)
mThumbnailer = new Thumbnailer(activity, activity.getWindowManager().getDefaultDisplay());
+ try {
+ mLibVlc = LibVLC.getInstance();
+ } catch (LibVlcException e) {}
}
@Override
@@ -340,10 +347,18 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
private void setContextMenuItems(Menu menu, Media media) {
long lastTime = media.getTime();
- if (lastTime > 0) {
- MenuItem playFromStart = menu.findItem(R.id.video_list_play_from_start);
- playFromStart.setVisible(true);
+ if (lastTime > 0)
+ menu.findItem(R.id.video_list_play_from_start).setVisible(true);
+
+ boolean hasInfo = false;
+ TrackInfo[] tracks = mLibVlc.readTracksInfo(media.getLocation());
+ for (TrackInfo track : tracks) {
+ if (track.Type != TrackInfo.TYPE_META) {
+ hasInfo = true;
+ break;
+ }
}
+ menu.findItem(R.id.video_list_info).setVisible(hasInfo);
}
@Override
More information about the Android
mailing list