[Android] MediaWrapper: don't fetch meta/tracks if not parsed

Thomas Guillem git at videolan.org
Tue Jan 20 14:57:47 CET 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jan 20 11:20:24 2015 +0100| [5d57c389bf3e0d1fcfdef80a4f4980e98ec1af6f] | committer: Thomas Guillem

MediaWrapper: don't fetch meta/tracks if not parsed

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

 vlc-android/src/org/videolan/vlc/MediaWrapper.java |   26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaWrapper.java b/vlc-android/src/org/videolan/vlc/MediaWrapper.java
index d7ec09f..93f161e 100644
--- a/vlc-android/src/org/videolan/vlc/MediaWrapper.java
+++ b/vlc-android/src/org/videolan/vlc/MediaWrapper.java
@@ -104,17 +104,19 @@ public class MediaWrapper implements Parcelable {
 
         mType = TYPE_ALL;
 
-        for (int i = 0; i < media.getTrackCount(); ++i) {
-            final Media.Track track = media.getTrack(i);
-            if (track == null)
-                continue;
-            if (track.type == Media.Track.Type.Video) {
-                final Media.VideoTrack videoTrack = (VideoTrack) track;
-                mType = TYPE_VIDEO;
-                mWidth = videoTrack.width;
-                mHeight = videoTrack.height;
-            } else if (mType == TYPE_ALL && track.type == Media.Track.Type.Audio){
-                mType = TYPE_AUDIO;
+        if (media.isParsed()) {
+            for (int i = 0; i < media.getTrackCount(); ++i) {
+                final Media.Track track = media.getTrack(i);
+                if (track == null)
+                    continue;
+                if (track.type == Media.Track.Type.Video) {
+                    final Media.VideoTrack videoTrack = (VideoTrack) track;
+                    mType = TYPE_VIDEO;
+                    mWidth = videoTrack.width;
+                    mHeight = videoTrack.height;
+                } else if (mType == TYPE_ALL && track.type == Media.Track.Type.Audio){
+                    mType = TYPE_AUDIO;
+                }
             }
         }
         if (mType == TYPE_ALL) {
@@ -190,6 +192,8 @@ public class MediaWrapper implements Parcelable {
     }
 
     public void updateMeta(Media media) {
+        if (!media.isParsed())
+            return;
         mTitle = getMetaId(media, Meta.Title, true);
         mArtist = getMetaId(media, Meta.Artist, true);
         mAlbum = getMetaId(media, Meta.Album, true);



More information about the Android mailing list