[Android] Use readTracksInfo when scanning medias. it's now at least 3 times faster
Sébastien Toque
git at videolan.org
Sun May 13 21:23:11 CEST 2012
android | branch: master | Sébastien Toque <xilasz at gmail.com> | Sun May 13 20:37:15 2012 +0200| [39b68902add33a26d5d1403eb3528f1b3c993d48] | committer: Sébastien Toque
Use readTracksInfo when scanning medias. it's now at least 3 times faster
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=39b68902add33a26d5d1403eb3528f1b3c993d48
---
vlc-android/src/org/videolan/vlc/Media.java | 29 +++++++++++++--------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/Media.java b/vlc-android/src/org/videolan/vlc/Media.java
index b69b4ed..c8369df 100644
--- a/vlc-android/src/org/videolan/vlc/Media.java
+++ b/vlc-android/src/org/videolan/vlc/Media.java
@@ -106,27 +106,26 @@ public class Media implements Comparable<Media> {
LibVLC mLibVlc = null;
try {
mLibVlc = LibVLC.getInstance();
- mType = (mLibVlc.hasVideoTrack(mLocation)) ? TYPE_VIDEO : TYPE_AUDIO;
- mLength = mLibVlc.getLengthFromLocation(mLocation);
+ mType = TYPE_AUDIO;
- String[] array = mLibVlc.readMediaMeta(mLocation);
+ TrackInfo[] tracks = mLibVlc.readTracksInfo(mLocation);
- int i;
- for (i = 0; i < array.length; i++) {
- String s = array[i++];
- String v = array[i];
+ for (TrackInfo track : tracks) {
+ if (track.Type == TrackInfo.TYPE_VIDEO) {
+ mType = TYPE_VIDEO;
+ mWidth = track.Width;
+ mHeight = track.Height;
+ }
- if (s.equals("title")) {
- mTitle = v;
+ if (track.Type == TrackInfo.TYPE_META) {
+ mLength = track.Length;
+ mTitle = track.Title;
+ mArtist = Util.getValue(context, track.Artist, R.string.unknown_artist);
+ mAlbum = Util.getValue(context, track.Album, R.string.unknown_album);
+ mGenre = Util.getValue(context, track.Genre, R.string.unknown_genre);
Log.d(TAG, "Title " + mTitle);
- } else if (s.equals("artist")) {
- mArtist = Util.getValue(context, v, R.string.unknown_artist);
Log.d(TAG, "Artist " + mArtist);
- } else if (s.equals("genre")) {
- mGenre = Util.getValue(context, v, R.string.unknown_genre);
Log.d(TAG, "Genre " + mGenre);
- } else if (s.equals("album")) {
- mAlbum = Util.getValue(context, v, R.string.unknown_album);
Log.d(TAG, "Album " + mAlbum);
}
}
More information about the Android
mailing list