[Android] [WIP PATCH 06/11] move Media to CustomMedia
Thomas Guillem
thomas at gllm.fr
Tue Dec 23 18:38:27 CET 2014
---
libvlc/src/org/videolan/libvlc/CustomMedia.java | 510 +++++++++++++++++++++
.../src/org/videolan/libvlc/CustomMediaList.java | 20 +-
libvlc/src/org/videolan/libvlc/Media.java | 510 ---------------------
.../src/org/videolan/vlc/MediaDatabase.java | 22 +-
vlc-android/src/org/videolan/vlc/MediaGroup.java | 28 +-
vlc-android/src/org/videolan/vlc/MediaLibrary.java | 56 +--
vlc-android/src/org/videolan/vlc/Thumbnailer.java | 8 +-
.../src/org/videolan/vlc/audio/AudioService.java | 20 +-
.../src/org/videolan/vlc/gui/BrowserActivity.java | 4 +-
.../src/org/videolan/vlc/gui/DirectoryAdapter.java | 6 +-
.../src/org/videolan/vlc/gui/HistoryAdapter.java | 4 +-
.../src/org/videolan/vlc/gui/SearchFragment.java | 14 +-
.../org/videolan/vlc/gui/SearchResultAdapter.java | 10 +-
.../vlc/gui/audio/AudioAlbumsSongsFragment.java | 10 +-
.../vlc/gui/audio/AudioBrowserFragment.java | 10 +-
.../vlc/gui/audio/AudioBrowserListAdapter.java | 32 +-
.../org/videolan/vlc/gui/audio/AudioPlayer.java | 6 +-
.../vlc/gui/audio/AudioPlaylistAdapter.java | 14 +-
.../src/org/videolan/vlc/gui/audio/AudioUtil.java | 12 +-
.../videolan/vlc/gui/audio/MediaComparators.java | 30 +-
.../videolan/vlc/gui/video/MediaInfoFragment.java | 4 +-
.../vlc/gui/video/VideoBrowserInterface.java | 4 +-
.../videolan/vlc/gui/video/VideoGridFragment.java | 26 +-
.../videolan/vlc/gui/video/VideoListAdapter.java | 18 +-
.../vlc/gui/video/VideoPlayerActivity.java | 8 +-
.../src/org/videolan/vlc/util/BitmapUtil.java | 4 +-
vlc-android/src/org/videolan/vlc/util/Util.java | 8 +-
27 files changed, 699 insertions(+), 699 deletions(-)
create mode 100644 libvlc/src/org/videolan/libvlc/CustomMedia.java
delete mode 100644 libvlc/src/org/videolan/libvlc/Media.java
diff --git a/libvlc/src/org/videolan/libvlc/CustomMedia.java b/libvlc/src/org/videolan/libvlc/CustomMedia.java
new file mode 100644
index 0000000..4773e6e
--- /dev/null
+++ b/libvlc/src/org/videolan/libvlc/CustomMedia.java
@@ -0,0 +1,510 @@
+/*****************************************************************************
+ * Media.java
+ *****************************************************************************
+ * Copyright © 2011-2013 VLC authors and VideoLAN
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+package org.videolan.libvlc;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Locale;
+
+import android.graphics.Bitmap;
+import android.text.TextUtils;
+import android.util.Log;
+
+public class CustomMedia implements Comparable<CustomMedia> {
+ public final static String TAG = "VLC/LibVLC/Media";
+
+ public final static HashSet<String> VIDEO_EXTENSIONS;
+ public final static HashSet<String> AUDIO_EXTENSIONS;
+ public final static String EXTENSIONS_REGEX;
+ public final static HashSet<String> FOLDER_BLACKLIST;
+
+ static {
+ String[] video_extensions = {
+ ".3g2", ".3gp", ".3gp2", ".3gpp", ".amv", ".asf", ".avi", ".divx", ".drc", ".dv",
+ ".f4v", ".flv", ".gvi", ".gxf", ".ismv", ".iso", ".m1v", ".m2v", ".m2t", ".m2ts",
+ ".m4v", ".mkv", ".mov", ".mp2", ".mp2v", ".mp4", ".mp4v", ".mpe", ".mpeg",
+ ".mpeg1", ".mpeg2", ".mpeg4", ".mpg", ".mpv2", ".mts", ".mtv", ".mxf", ".mxg",
+ ".nsv", ".nut", ".nuv", ".ogm", ".ogv", ".ogx", ".ps", ".rec", ".rm", ".rmvb",
+ ".tod", ".ts", ".tts", ".vob", ".vro", ".webm", ".wm", ".wmv", ".wtv", ".xesc" };
+
+ String[] audio_extensions = {
+ ".3ga", ".a52", ".aac", ".ac3", ".adt", ".adts", ".aif", ".aifc", ".aiff", ".amr",
+ ".aob", ".ape", ".awb", ".caf", ".dts", ".flac", ".it", ".m4a", ".m4b", ".m4p",
+ ".mid", ".mka", ".mlp", ".mod", ".mpa", ".mp1", ".mp2", ".mp3", ".mpc", ".mpga",
+ ".oga", ".ogg", ".oma", ".opus", ".ra", ".ram", ".rmi", ".s3m", ".spx", ".tta",
+ ".voc", ".vqf", ".w64", ".wav", ".wma", ".wv", ".xa", ".xm" };
+
+ String[] folder_blacklist = {
+ "/alarms",
+ "/notifications",
+ "/ringtones",
+ "/media/alarms",
+ "/media/notifications",
+ "/media/ringtones",
+ "/media/audio/alarms",
+ "/media/audio/notifications",
+ "/media/audio/ringtones",
+ "/Android/data/" };
+
+ VIDEO_EXTENSIONS = new HashSet<String>();
+ for (String item : video_extensions)
+ VIDEO_EXTENSIONS.add(item);
+ AUDIO_EXTENSIONS = new HashSet<String>();
+ for (String item : audio_extensions)
+ AUDIO_EXTENSIONS.add(item);
+
+ StringBuilder sb = new StringBuilder(115);
+ sb.append(".+(\\.)((?i)(");
+ sb.append(video_extensions[0].substring(1));
+ for(int i = 1; i < video_extensions.length; i++) {
+ sb.append('|');
+ sb.append(video_extensions[i].substring(1));
+ }
+ for(int i = 0; i < audio_extensions.length; i++) {
+ sb.append('|');
+ sb.append(audio_extensions[i].substring(1));
+ }
+ sb.append("))");
+ EXTENSIONS_REGEX = sb.toString();
+ FOLDER_BLACKLIST = new HashSet<String>();
+ for (String item : folder_blacklist)
+ FOLDER_BLACKLIST.add(android.os.Environment.getExternalStorageDirectory().getPath() + item);
+ }
+
+ public final static int TYPE_ALL = -1;
+ public final static int TYPE_VIDEO = 0;
+ public final static int TYPE_AUDIO = 1;
+ public final static int TYPE_GROUP = 2;
+
+ /** Metadata from libvlc_media */
+ protected String mTitle;
+ private String mArtist;
+ private String mGenre;
+ private String mCopyright;
+ private String mAlbum;
+ private int mTrackNumber;
+ private String mAlbumArtist;
+ private String mDescription;
+ private String mRating;
+ private String mDate;
+ private String mSettings;
+ private String mNowPlaying;
+ private String mPublisher;
+ private String mEncodedBy;
+ private String mTrackID;
+ private String mArtworkURL;
+
+ public final static int libvlc_meta_Title = 0;
+ public final static int libvlc_meta_Artist = 1;
+ public final static int libvlc_meta_Genre = 2;
+// public final static int libvlc_meta_Copyright = 3;
+ public final static int libvlc_meta_Album = 4;
+// public final static int libvlc_meta_TrackNumber = 5;
+// public final static int libvlc_meta_Description = 6;
+// public final static int libvlc_meta_Rating = 7;
+// public final static int libvlc_meta_Date = 8;
+// public final static int libvlc_meta_Setting = 9;
+// public final static int libvlc_meta_URL = 10;
+// public final static int libvlc_meta_Language = 11;
+ public final static int libvlc_meta_NowPlaying = 12;
+// public final static int libvlc_meta_Publisher = 13;
+// public final static int libvlc_meta_EncodedBy = 14;
+ public final static int libvlc_meta_ArtworkURL = 15;
+// public final static int libvlc_meta_TrackID = 16;
+// public final static int libvlc_meta_TrackTotal = 17;
+// public final static int libvlc_meta_Director = 18;
+// public final static int libvlc_meta_Season = 19;
+// public final static int libvlc_meta_Episode = 20;
+// public final static int libvlc_meta_ShowName = 21;
+// public final static int libvlc_meta_Actors = 22;
+
+ private final String mLocation;
+ private String mFilename;
+ private long mTime = 0;
+ private int mAudioTrack = -1;
+ private int mSpuTrack = -2;
+ private long mLength = 0;
+ private int mType;
+ private int mWidth = 0;
+ private int mHeight = 0;
+ private Bitmap mPicture;
+ private boolean mIsPictureParsed;
+
+ /**
+ * Create a new Media
+ * @param libVLC A pointer to the libVLC instance. Should not be NULL
+ * @param URI The URI of the media.
+ */
+ public CustomMedia(LibVLC libVLC, String URI) {
+ if(libVLC == null)
+ throw new NullPointerException("libVLC was null");
+
+ mLocation = URI;
+
+ mType = TYPE_ALL;
+ TrackInfo[] tracks = libVLC.readTracksInfo(mLocation);
+
+ extractTrackInfo(tracks);
+ }
+
+ private void extractTrackInfo(TrackInfo[] tracks) {
+ if (tracks == null) {
+ mTitle = null;
+ mArtist = getValueWrapper(null, UnknownStringType.Artist).trim();
+ mAlbum = getValueWrapper(null, UnknownStringType.Album).trim();
+ mGenre = getValueWrapper(null, UnknownStringType.Genre).trim();
+ mAlbumArtist = getValueWrapper(null, UnknownStringType.AlbumArtist).trim();
+ return;
+ }
+
+ for (TrackInfo track : tracks) {
+ if (track.Type == TrackInfo.TYPE_VIDEO) {
+ mType = TYPE_VIDEO;
+ mWidth = track.Width;
+ mHeight = track.Height;
+ } else if (mType == TYPE_ALL && track.Type == TrackInfo.TYPE_AUDIO){
+ mType = TYPE_AUDIO;
+ } else if (track.Type == TrackInfo.TYPE_META) {
+ mLength = track.Length;
+ mTitle = track.Title != null ? track.Title.trim() : null;
+ mArtist = getValueWrapper(track.Artist, UnknownStringType.Artist).trim();
+ mAlbum = getValueWrapper(track.Album, UnknownStringType.Album).trim();
+ mGenre = getValueWrapper(track.Genre, UnknownStringType.Genre).trim();
+ mAlbumArtist = getValueWrapper(track.AlbumArtist, UnknownStringType.AlbumArtist).trim();
+ mArtworkURL = track.ArtworkURL;
+ mNowPlaying = track.NowPlaying;
+ if (!TextUtils.isEmpty(track.TrackNumber)) {
+ try {
+ mTrackNumber = Integer.parseInt(track.TrackNumber);
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ Log.d(TAG, "Title " + mTitle);
+ Log.d(TAG, "Artist " + mArtist);
+ Log.d(TAG, "Genre " + mGenre);
+ Log.d(TAG, "Album " + mAlbum);
+ }
+ }
+
+ /* No useful ES found */
+ if (mType == TYPE_ALL) {
+ int dotIndex = mLocation.lastIndexOf(".");
+ if (dotIndex != -1) {
+ String fileExt = mLocation.substring(dotIndex).toLowerCase(Locale.ENGLISH);
+ if( CustomMedia.VIDEO_EXTENSIONS.contains(fileExt) ) {
+ mType = TYPE_VIDEO;
+ } else if (CustomMedia.AUDIO_EXTENSIONS.contains(fileExt)) {
+ mType = TYPE_AUDIO;
+ }
+ }
+ }
+ }
+
+ public CustomMedia(String location, long time, long length, int type,
+ Bitmap picture, String title, String artist, String genre, String album, String albumArtist,
+ int width, int height, String artworkURL, int audio, int spu, int trackNumber) {
+ mLocation = location;
+ mFilename = null;
+ mTime = time;
+ mAudioTrack = audio;
+ mSpuTrack = spu;
+ mLength = length;
+ mType = type;
+ mPicture = picture;
+ mWidth = width;
+ mHeight = height;
+
+ mTitle = title;
+ mArtist = getValueWrapper(artist, UnknownStringType.Artist);
+ mGenre = getValueWrapper(genre, UnknownStringType.Genre);
+ mAlbum = getValueWrapper(album, UnknownStringType.Album);
+ mAlbumArtist = getValueWrapper(albumArtist, UnknownStringType.AlbumArtist);
+ mArtworkURL = artworkURL;
+ mTrackNumber = trackNumber;
+ }
+
+ private enum UnknownStringType { Artist , Genre, Album, AlbumArtist };
+ /**
+ * Uses introspection to read VLC l10n databases, so that we can sever the
+ * hard-coded dependency gracefully for 3rd party libvlc apps while still
+ * maintaining good l10n in VLC for Android.
+ *
+ * @see org.videolan.vlc.util.Util#getValue(String, int)
+ *
+ * @param string The default string
+ * @param type Alias for R.string.xxx
+ * @return The default string if not empty or string from introspection
+ */
+ private static String getValueWrapper(String string, UnknownStringType type) {
+ if(string != null && string.length() > 0) return string;
+
+ try {
+ Class<?> stringClass = Class.forName("org.videolan.vlc.R$string");
+ Class<?> utilClass = Class.forName("org.videolan.vlc.Util");
+
+ Integer value;
+ switch(type) {
+ case Album:
+ value = (Integer)stringClass.getField("unknown_album").get(null);
+ break;
+ case Genre:
+ value = (Integer)stringClass.getField("unknown_genre").get(null);
+ break;
+ case AlbumArtist:
+ value = (Integer)stringClass.getField("unknown_artist").get(null);
+ break;
+ case Artist:
+ default:
+ value = (Integer)stringClass.getField("unknown_artist").get(null);
+ break;
+ }
+
+ Method getValueMethod = utilClass.getDeclaredMethod("getValue", String.class, Integer.TYPE);
+ // Util.getValue(string, R.string.xxx);
+ return (String) getValueMethod.invoke(null, string, value);
+ } catch (ClassNotFoundException e) {
+ } catch (IllegalArgumentException e) {
+ } catch (IllegalAccessException e) {
+ } catch (NoSuchFieldException e) {
+ } catch (NoSuchMethodException e) {
+ } catch (InvocationTargetException e) {
+ }
+
+ // VLC for Android translations not available (custom app perhaps)
+ // Use hardcoded English phrases.
+ switch(type) {
+ case Album:
+ return "Unknown Album";
+ case Genre:
+ return "Unknown Genre";
+ case Artist:
+ default:
+ return "Unknown Artist";
+ }
+ }
+
+ /**
+ * Compare the filenames to sort items
+ */
+ @Override
+ public int compareTo(CustomMedia another) {
+ return getTitle().toUpperCase(Locale.getDefault()).compareTo(
+ another.getTitle().toUpperCase(Locale.getDefault()));
+ }
+
+ public String getLocation() {
+ return mLocation;
+ }
+
+ public void updateMeta(LibVLC libVLC) {
+ mTitle = libVLC.getMeta(libvlc_meta_Title);
+ mArtist = getValueWrapper(libVLC.getMeta(libvlc_meta_Artist), UnknownStringType.Artist);
+ mGenre = getValueWrapper(libVLC.getMeta(libvlc_meta_Genre), UnknownStringType.Genre);
+ mAlbum = getValueWrapper(libVLC.getMeta(libvlc_meta_Album), UnknownStringType.Album);
+ mNowPlaying = libVLC.getMeta(libvlc_meta_NowPlaying);
+ mArtworkURL = libVLC.getMeta(libvlc_meta_ArtworkURL);
+ }
+
+ public String getFileName() {
+ if (mFilename == null) {
+ mFilename = LibVlcUtil.URItoFileName(mLocation);
+ }
+ return mFilename;
+ }
+
+ public long getTime() {
+ return mTime;
+ }
+
+ public void setTime(long time) {
+ mTime = time;
+ }
+
+ public int getAudioTrack() {
+ return mAudioTrack;
+ }
+
+ public void setAudioTrack(int track) {
+ mAudioTrack = track;
+ }
+
+ public int getSpuTrack() {
+ return mSpuTrack;
+ }
+
+ public void setSpuTrack(int track) {
+ mSpuTrack = track;
+ }
+
+ public long getLength() {
+ return mLength;
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ public int getWidth() {
+ return mWidth;
+ }
+
+ public int getHeight() {
+ return mHeight;
+ }
+
+ /**
+ * Returns the raw picture object. Likely to be NULL in VLC for Android
+ * due to lazy-loading.
+ *
+ * Use {@link org.videolan.vlc.util.Bitmap#getPictureFromCache(CustomMedia)} instead.
+ *
+ * @return The raw picture or NULL
+ */
+ public Bitmap getPicture() {
+ return mPicture;
+ }
+
+ /**
+ * Sets the raw picture object.
+ *
+ * In VLC for Android, use {@link org.videolan.vlc.MediaDatabase#setPicture(CustomMedia, Bitmap)} instead.
+ *
+ * @param p
+ */
+ public void setPicture(Bitmap p) {
+ mPicture = p;
+ }
+
+ public boolean isPictureParsed() {
+ return mIsPictureParsed;
+ }
+
+ public void setPictureParsed(boolean isParsed) {
+ mIsPictureParsed = isParsed;
+ }
+
+ public String getTitle() {
+ if (mTitle != null && mType != TYPE_VIDEO)
+ return mTitle;
+ else {
+ String fileName = getFileName();
+ if (fileName == null)
+ return "";
+ int end = fileName.lastIndexOf(".");
+ if (end <= 0)
+ return fileName;
+ return fileName.substring(0, end);
+ }
+ }
+
+ public String getSubtitle() {
+ return mType != TYPE_VIDEO ?
+ mNowPlaying != null ?
+ mNowPlaying
+ : mArtist + " - " + mAlbum
+ : "";
+ }
+
+ public String getReferenceArtist() {
+ if (isAlbumArtistUnknown())
+ return mArtist;
+ else
+ return mAlbumArtist;
+ }
+
+ public String getArtist() {
+ return mArtist;
+ }
+
+ public Boolean isAlbumArtistUnknown() {
+ return (mAlbumArtist.equals(getValueWrapper(null, UnknownStringType.AlbumArtist)));
+ }
+
+ public Boolean isArtistUnknown() {
+ return (mArtist.equals(getValueWrapper(null, UnknownStringType.Artist)));
+ }
+
+ public String getGenre() {
+ if(getValueWrapper(null, UnknownStringType.Genre).equals(mGenre))
+ return mGenre;
+ else if( mGenre.length() > 1)/* Make genres case insensitive via normalisation */
+ return Character.toUpperCase(mGenre.charAt(0)) + mGenre.substring(1).toLowerCase(Locale.getDefault());
+ else
+ return mGenre;
+ }
+
+ public String getCopyright() {
+ return mCopyright;
+ }
+
+ public String getAlbum() {
+ return mAlbum;
+ }
+
+ public String getAlbumArtist() {
+ return mAlbumArtist;
+ }
+
+ public Boolean isAlbumUnknown() {
+ return (mAlbum.equals(getValueWrapper(null, UnknownStringType.Album)));
+ }
+
+ public int getTrackNumber() {
+ return mTrackNumber;
+ }
+
+ public String getDescription() {
+ return mDescription;
+ }
+
+ public String getRating() {
+ return mRating;
+ }
+
+ public String getDate() {
+ return mDate;
+ }
+
+ public String getSettings() {
+ return mSettings;
+ }
+
+ public String getNowPlaying() {
+ return mNowPlaying;
+ }
+
+ public String getPublisher() {
+ return mPublisher;
+ }
+
+ public String getEncodedBy() {
+ return mEncodedBy;
+ }
+
+ public String getTrackID() {
+ return mTrackID;
+ }
+
+ public String getArtworkURL() {
+ return mArtworkURL;
+ }
+}
diff --git a/libvlc/src/org/videolan/libvlc/CustomMediaList.java b/libvlc/src/org/videolan/libvlc/CustomMediaList.java
index 39bff71..ade0fcf 100644
--- a/libvlc/src/org/videolan/libvlc/CustomMediaList.java
+++ b/libvlc/src/org/videolan/libvlc/CustomMediaList.java
@@ -30,14 +30,14 @@ public class CustomMediaList {
/* Since the libvlc_media_t is not created until the media plays, we have
* to cache them here. */
private static class MediaHolder {
- Media m;
+ CustomMedia m;
boolean noVideo; // default false
boolean noHardwareAcceleration; // default false
- public MediaHolder(Media media) {
+ public MediaHolder(CustomMedia media) {
m = media; noVideo = false; noHardwareAcceleration = false;
}
- public MediaHolder(Media m_, boolean noVideo_, boolean noHardwareAcceleration_) {
+ public MediaHolder(CustomMedia m_, boolean noVideo_, boolean noHardwareAcceleration_) {
m = m_; noVideo = noVideo_; noHardwareAcceleration = noHardwareAcceleration_;
}
}
@@ -62,15 +62,15 @@ public class CustomMediaList {
* to a MRL.
*/
public void add(String mrl) {
- add(new Media(mLibVLC, mrl));
+ add(new CustomMedia(mLibVLC, mrl));
}
- public void add(Media media) {
+ public void add(CustomMedia media) {
add(media, false, false);
}
- public void add(Media media, boolean noVideo) {
+ public void add(CustomMedia media, boolean noVideo) {
add(media, noVideo, false);
}
- public void add(Media media, boolean noVideo, boolean noHardwareAcceleration) {
+ public void add(CustomMedia media, boolean noVideo, boolean noHardwareAcceleration) {
mInternalList.add(new MediaHolder(media, noVideo, noHardwareAcceleration));
signal_list_event(EventHandler.CustomMediaListItemAdded, mInternalList.size() - 1, media.getLocation());
}
@@ -113,9 +113,9 @@ public class CustomMediaList {
}
public void insert(int position, String mrl) {
- insert(position, new Media(mLibVLC, mrl));
+ insert(position, new CustomMedia(mLibVLC, mrl));
}
- public void insert(int position, Media media) {
+ public void insert(int position, CustomMedia media) {
mInternalList.add(position, new MediaHolder(media));
signal_list_event(EventHandler.CustomMediaListItemAdded, position, media.getLocation());
}
@@ -167,7 +167,7 @@ public class CustomMediaList {
return mInternalList.size();
}
- public Media getMedia(int position) {
+ public CustomMedia getMedia(int position) {
if (!isValid(position))
return null;
return mInternalList.get(position).m;
diff --git a/libvlc/src/org/videolan/libvlc/Media.java b/libvlc/src/org/videolan/libvlc/Media.java
deleted file mode 100644
index 8dd0b0f..0000000
--- a/libvlc/src/org/videolan/libvlc/Media.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*****************************************************************************
- * Media.java
- *****************************************************************************
- * Copyright © 2011-2013 VLC authors and VideoLAN
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-package org.videolan.libvlc;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Locale;
-
-import android.graphics.Bitmap;
-import android.text.TextUtils;
-import android.util.Log;
-
-public class Media implements Comparable<Media> {
- public final static String TAG = "VLC/LibVLC/Media";
-
- public final static HashSet<String> VIDEO_EXTENSIONS;
- public final static HashSet<String> AUDIO_EXTENSIONS;
- public final static String EXTENSIONS_REGEX;
- public final static HashSet<String> FOLDER_BLACKLIST;
-
- static {
- String[] video_extensions = {
- ".3g2", ".3gp", ".3gp2", ".3gpp", ".amv", ".asf", ".avi", ".divx", ".drc", ".dv",
- ".f4v", ".flv", ".gvi", ".gxf", ".ismv", ".iso", ".m1v", ".m2v", ".m2t", ".m2ts",
- ".m4v", ".mkv", ".mov", ".mp2", ".mp2v", ".mp4", ".mp4v", ".mpe", ".mpeg",
- ".mpeg1", ".mpeg2", ".mpeg4", ".mpg", ".mpv2", ".mts", ".mtv", ".mxf", ".mxg",
- ".nsv", ".nut", ".nuv", ".ogm", ".ogv", ".ogx", ".ps", ".rec", ".rm", ".rmvb",
- ".tod", ".ts", ".tts", ".vob", ".vro", ".webm", ".wm", ".wmv", ".wtv", ".xesc" };
-
- String[] audio_extensions = {
- ".3ga", ".a52", ".aac", ".ac3", ".adt", ".adts", ".aif", ".aifc", ".aiff", ".amr",
- ".aob", ".ape", ".awb", ".caf", ".dts", ".flac", ".it", ".m4a", ".m4b", ".m4p",
- ".mid", ".mka", ".mlp", ".mod", ".mpa", ".mp1", ".mp2", ".mp3", ".mpc", ".mpga",
- ".oga", ".ogg", ".oma", ".opus", ".ra", ".ram", ".rmi", ".s3m", ".spx", ".tta",
- ".voc", ".vqf", ".w64", ".wav", ".wma", ".wv", ".xa", ".xm" };
-
- String[] folder_blacklist = {
- "/alarms",
- "/notifications",
- "/ringtones",
- "/media/alarms",
- "/media/notifications",
- "/media/ringtones",
- "/media/audio/alarms",
- "/media/audio/notifications",
- "/media/audio/ringtones",
- "/Android/data/" };
-
- VIDEO_EXTENSIONS = new HashSet<String>();
- for (String item : video_extensions)
- VIDEO_EXTENSIONS.add(item);
- AUDIO_EXTENSIONS = new HashSet<String>();
- for (String item : audio_extensions)
- AUDIO_EXTENSIONS.add(item);
-
- StringBuilder sb = new StringBuilder(115);
- sb.append(".+(\\.)((?i)(");
- sb.append(video_extensions[0].substring(1));
- for(int i = 1; i < video_extensions.length; i++) {
- sb.append('|');
- sb.append(video_extensions[i].substring(1));
- }
- for(int i = 0; i < audio_extensions.length; i++) {
- sb.append('|');
- sb.append(audio_extensions[i].substring(1));
- }
- sb.append("))");
- EXTENSIONS_REGEX = sb.toString();
- FOLDER_BLACKLIST = new HashSet<String>();
- for (String item : folder_blacklist)
- FOLDER_BLACKLIST.add(android.os.Environment.getExternalStorageDirectory().getPath() + item);
- }
-
- public final static int TYPE_ALL = -1;
- public final static int TYPE_VIDEO = 0;
- public final static int TYPE_AUDIO = 1;
- public final static int TYPE_GROUP = 2;
-
- /** Metadata from libvlc_media */
- protected String mTitle;
- private String mArtist;
- private String mGenre;
- private String mCopyright;
- private String mAlbum;
- private int mTrackNumber;
- private String mAlbumArtist;
- private String mDescription;
- private String mRating;
- private String mDate;
- private String mSettings;
- private String mNowPlaying;
- private String mPublisher;
- private String mEncodedBy;
- private String mTrackID;
- private String mArtworkURL;
-
- public final static int libvlc_meta_Title = 0;
- public final static int libvlc_meta_Artist = 1;
- public final static int libvlc_meta_Genre = 2;
-// public final static int libvlc_meta_Copyright = 3;
- public final static int libvlc_meta_Album = 4;
-// public final static int libvlc_meta_TrackNumber = 5;
-// public final static int libvlc_meta_Description = 6;
-// public final static int libvlc_meta_Rating = 7;
-// public final static int libvlc_meta_Date = 8;
-// public final static int libvlc_meta_Setting = 9;
-// public final static int libvlc_meta_URL = 10;
-// public final static int libvlc_meta_Language = 11;
- public final static int libvlc_meta_NowPlaying = 12;
-// public final static int libvlc_meta_Publisher = 13;
-// public final static int libvlc_meta_EncodedBy = 14;
- public final static int libvlc_meta_ArtworkURL = 15;
-// public final static int libvlc_meta_TrackID = 16;
-// public final static int libvlc_meta_TrackTotal = 17;
-// public final static int libvlc_meta_Director = 18;
-// public final static int libvlc_meta_Season = 19;
-// public final static int libvlc_meta_Episode = 20;
-// public final static int libvlc_meta_ShowName = 21;
-// public final static int libvlc_meta_Actors = 22;
-
- private final String mLocation;
- private String mFilename;
- private long mTime = 0;
- private int mAudioTrack = -1;
- private int mSpuTrack = -2;
- private long mLength = 0;
- private int mType;
- private int mWidth = 0;
- private int mHeight = 0;
- private Bitmap mPicture;
- private boolean mIsPictureParsed;
-
- /**
- * Create a new Media
- * @param libVLC A pointer to the libVLC instance. Should not be NULL
- * @param URI The URI of the media.
- */
- public Media(LibVLC libVLC, String URI) {
- if(libVLC == null)
- throw new NullPointerException("libVLC was null");
-
- mLocation = URI;
-
- mType = TYPE_ALL;
- TrackInfo[] tracks = libVLC.readTracksInfo(mLocation);
-
- extractTrackInfo(tracks);
- }
-
- private void extractTrackInfo(TrackInfo[] tracks) {
- if (tracks == null) {
- mTitle = null;
- mArtist = getValueWrapper(null, UnknownStringType.Artist).trim();
- mAlbum = getValueWrapper(null, UnknownStringType.Album).trim();
- mGenre = getValueWrapper(null, UnknownStringType.Genre).trim();
- mAlbumArtist = getValueWrapper(null, UnknownStringType.AlbumArtist).trim();
- return;
- }
-
- for (TrackInfo track : tracks) {
- if (track.Type == TrackInfo.TYPE_VIDEO) {
- mType = TYPE_VIDEO;
- mWidth = track.Width;
- mHeight = track.Height;
- } else if (mType == TYPE_ALL && track.Type == TrackInfo.TYPE_AUDIO){
- mType = TYPE_AUDIO;
- } else if (track.Type == TrackInfo.TYPE_META) {
- mLength = track.Length;
- mTitle = track.Title != null ? track.Title.trim() : null;
- mArtist = getValueWrapper(track.Artist, UnknownStringType.Artist).trim();
- mAlbum = getValueWrapper(track.Album, UnknownStringType.Album).trim();
- mGenre = getValueWrapper(track.Genre, UnknownStringType.Genre).trim();
- mAlbumArtist = getValueWrapper(track.AlbumArtist, UnknownStringType.AlbumArtist).trim();
- mArtworkURL = track.ArtworkURL;
- mNowPlaying = track.NowPlaying;
- if (!TextUtils.isEmpty(track.TrackNumber)) {
- try {
- mTrackNumber = Integer.parseInt(track.TrackNumber);
- } catch (NumberFormatException ignored) {
- }
- }
- Log.d(TAG, "Title " + mTitle);
- Log.d(TAG, "Artist " + mArtist);
- Log.d(TAG, "Genre " + mGenre);
- Log.d(TAG, "Album " + mAlbum);
- }
- }
-
- /* No useful ES found */
- if (mType == TYPE_ALL) {
- int dotIndex = mLocation.lastIndexOf(".");
- if (dotIndex != -1) {
- String fileExt = mLocation.substring(dotIndex).toLowerCase(Locale.ENGLISH);
- if( Media.VIDEO_EXTENSIONS.contains(fileExt) ) {
- mType = TYPE_VIDEO;
- } else if (Media.AUDIO_EXTENSIONS.contains(fileExt)) {
- mType = TYPE_AUDIO;
- }
- }
- }
- }
-
- public Media(String location, long time, long length, int type,
- Bitmap picture, String title, String artist, String genre, String album, String albumArtist,
- int width, int height, String artworkURL, int audio, int spu, int trackNumber) {
- mLocation = location;
- mFilename = null;
- mTime = time;
- mAudioTrack = audio;
- mSpuTrack = spu;
- mLength = length;
- mType = type;
- mPicture = picture;
- mWidth = width;
- mHeight = height;
-
- mTitle = title;
- mArtist = getValueWrapper(artist, UnknownStringType.Artist);
- mGenre = getValueWrapper(genre, UnknownStringType.Genre);
- mAlbum = getValueWrapper(album, UnknownStringType.Album);
- mAlbumArtist = getValueWrapper(albumArtist, UnknownStringType.AlbumArtist);
- mArtworkURL = artworkURL;
- mTrackNumber = trackNumber;
- }
-
- private enum UnknownStringType { Artist , Genre, Album, AlbumArtist };
- /**
- * Uses introspection to read VLC l10n databases, so that we can sever the
- * hard-coded dependency gracefully for 3rd party libvlc apps while still
- * maintaining good l10n in VLC for Android.
- *
- * @see org.videolan.vlc.util.Util#getValue(String, int)
- *
- * @param string The default string
- * @param type Alias for R.string.xxx
- * @return The default string if not empty or string from introspection
- */
- private static String getValueWrapper(String string, UnknownStringType type) {
- if(string != null && string.length() > 0) return string;
-
- try {
- Class<?> stringClass = Class.forName("org.videolan.vlc.R$string");
- Class<?> utilClass = Class.forName("org.videolan.vlc.Util");
-
- Integer value;
- switch(type) {
- case Album:
- value = (Integer)stringClass.getField("unknown_album").get(null);
- break;
- case Genre:
- value = (Integer)stringClass.getField("unknown_genre").get(null);
- break;
- case AlbumArtist:
- value = (Integer)stringClass.getField("unknown_artist").get(null);
- break;
- case Artist:
- default:
- value = (Integer)stringClass.getField("unknown_artist").get(null);
- break;
- }
-
- Method getValueMethod = utilClass.getDeclaredMethod("getValue", String.class, Integer.TYPE);
- // Util.getValue(string, R.string.xxx);
- return (String) getValueMethod.invoke(null, string, value);
- } catch (ClassNotFoundException e) {
- } catch (IllegalArgumentException e) {
- } catch (IllegalAccessException e) {
- } catch (NoSuchFieldException e) {
- } catch (NoSuchMethodException e) {
- } catch (InvocationTargetException e) {
- }
-
- // VLC for Android translations not available (custom app perhaps)
- // Use hardcoded English phrases.
- switch(type) {
- case Album:
- return "Unknown Album";
- case Genre:
- return "Unknown Genre";
- case Artist:
- default:
- return "Unknown Artist";
- }
- }
-
- /**
- * Compare the filenames to sort items
- */
- @Override
- public int compareTo(Media another) {
- return getTitle().toUpperCase(Locale.getDefault()).compareTo(
- another.getTitle().toUpperCase(Locale.getDefault()));
- }
-
- public String getLocation() {
- return mLocation;
- }
-
- public void updateMeta(LibVLC libVLC) {
- mTitle = libVLC.getMeta(libvlc_meta_Title);
- mArtist = getValueWrapper(libVLC.getMeta(libvlc_meta_Artist), UnknownStringType.Artist);
- mGenre = getValueWrapper(libVLC.getMeta(libvlc_meta_Genre), UnknownStringType.Genre);
- mAlbum = getValueWrapper(libVLC.getMeta(libvlc_meta_Album), UnknownStringType.Album);
- mNowPlaying = libVLC.getMeta(libvlc_meta_NowPlaying);
- mArtworkURL = libVLC.getMeta(libvlc_meta_ArtworkURL);
- }
-
- public String getFileName() {
- if (mFilename == null) {
- mFilename = LibVlcUtil.URItoFileName(mLocation);
- }
- return mFilename;
- }
-
- public long getTime() {
- return mTime;
- }
-
- public void setTime(long time) {
- mTime = time;
- }
-
- public int getAudioTrack() {
- return mAudioTrack;
- }
-
- public void setAudioTrack(int track) {
- mAudioTrack = track;
- }
-
- public int getSpuTrack() {
- return mSpuTrack;
- }
-
- public void setSpuTrack(int track) {
- mSpuTrack = track;
- }
-
- public long getLength() {
- return mLength;
- }
-
- public int getType() {
- return mType;
- }
-
- public int getWidth() {
- return mWidth;
- }
-
- public int getHeight() {
- return mHeight;
- }
-
- /**
- * Returns the raw picture object. Likely to be NULL in VLC for Android
- * due to lazy-loading.
- *
- * Use {@link org.videolan.vlc.util.Bitmap#getPictureFromCache(Media)} instead.
- *
- * @return The raw picture or NULL
- */
- public Bitmap getPicture() {
- return mPicture;
- }
-
- /**
- * Sets the raw picture object.
- *
- * In VLC for Android, use {@link org.videolan.vlc.MediaDatabase#setPicture(Media, Bitmap)} instead.
- *
- * @param p
- */
- public void setPicture(Bitmap p) {
- mPicture = p;
- }
-
- public boolean isPictureParsed() {
- return mIsPictureParsed;
- }
-
- public void setPictureParsed(boolean isParsed) {
- mIsPictureParsed = isParsed;
- }
-
- public String getTitle() {
- if (mTitle != null && mType != TYPE_VIDEO)
- return mTitle;
- else {
- String fileName = getFileName();
- if (fileName == null)
- return "";
- int end = fileName.lastIndexOf(".");
- if (end <= 0)
- return fileName;
- return fileName.substring(0, end);
- }
- }
-
- public String getSubtitle() {
- return mType != TYPE_VIDEO ?
- mNowPlaying != null ?
- mNowPlaying
- : mArtist + " - " + mAlbum
- : "";
- }
-
- public String getReferenceArtist() {
- if (isAlbumArtistUnknown())
- return mArtist;
- else
- return mAlbumArtist;
- }
-
- public String getArtist() {
- return mArtist;
- }
-
- public Boolean isAlbumArtistUnknown() {
- return (mAlbumArtist.equals(getValueWrapper(null, UnknownStringType.AlbumArtist)));
- }
-
- public Boolean isArtistUnknown() {
- return (mArtist.equals(getValueWrapper(null, UnknownStringType.Artist)));
- }
-
- public String getGenre() {
- if(getValueWrapper(null, UnknownStringType.Genre).equals(mGenre))
- return mGenre;
- else if( mGenre.length() > 1)/* Make genres case insensitive via normalisation */
- return Character.toUpperCase(mGenre.charAt(0)) + mGenre.substring(1).toLowerCase(Locale.getDefault());
- else
- return mGenre;
- }
-
- public String getCopyright() {
- return mCopyright;
- }
-
- public String getAlbum() {
- return mAlbum;
- }
-
- public String getAlbumArtist() {
- return mAlbumArtist;
- }
-
- public Boolean isAlbumUnknown() {
- return (mAlbum.equals(getValueWrapper(null, UnknownStringType.Album)));
- }
-
- public int getTrackNumber() {
- return mTrackNumber;
- }
-
- public String getDescription() {
- return mDescription;
- }
-
- public String getRating() {
- return mRating;
- }
-
- public String getDate() {
- return mDate;
- }
-
- public String getSettings() {
- return mSettings;
- }
-
- public String getNowPlaying() {
- return mNowPlaying;
- }
-
- public String getPublisher() {
- return mPublisher;
- }
-
- public String getEncodedBy() {
- return mEncodedBy;
- }
-
- public String getTrackID() {
- return mTrackID;
- }
-
- public String getArtworkURL() {
- return mArtworkURL;
- }
-}
diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index 41a4694..1ba035e 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -31,7 +31,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Set;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import android.content.ContentValues;
import android.content.Context;
@@ -471,7 +471,7 @@ public class MediaDatabase {
* Add a new media to the database. The picture can only added by update.
* @param media which you like to add to the database
*/
- public synchronized void addMedia(Media media) {
+ public synchronized void addMedia(CustomMedia media) {
ContentValues values = new ContentValues();
@@ -549,7 +549,7 @@ public class MediaDatabase {
String[] queryColumns = new String[]{MEDIA_LOCATION, MEDIA_TITLE, MEDIA_ALBUM, MEDIA_ARTIST, MEDIA_TYPE};
String queryString = MEDIA_TITLE+" LIKE ? OR "+MEDIA_ALBUM+" LIKE ? OR "+MEDIA_ARTIST+" LIKE ?";
String [] queryArgs;
- if (type != Media.TYPE_ALL) {
+ if (type != CustomMedia.TYPE_ALL) {
queryString = "( " + queryString + " ) AND " + MEDIA_TYPE + "=?";
queryArgs = new String[]{"%"+filter+"%", "%"+filter+"%", "%"+filter+"%", String.valueOf(type)};
} else
@@ -566,10 +566,10 @@ public class MediaDatabase {
return mediaList;
}
- public synchronized HashMap<String, Media> getMedias() {
+ public synchronized HashMap<String, CustomMedia> getMedias() {
Cursor cursor;
- HashMap<String, Media> medias = new HashMap<String, Media>();
+ HashMap<String, CustomMedia> medias = new HashMap<String, CustomMedia>();
int chunk_count = 0;
int count = 0;
@@ -599,7 +599,7 @@ public class MediaDatabase {
if (cursor.moveToFirst()) {
do {
String location = cursor.getString(14);
- Media media = new Media(location,
+ CustomMedia media = new CustomMedia(location,
cursor.getLong(0), // MEDIA_TIME
cursor.getLong(1), // MEDIA_LENGTH
cursor.getInt(2), // MEDIA_TYPE
@@ -643,7 +643,7 @@ public class MediaDatabase {
MEDIA_TIME, //1 long
MEDIA_TABLE_NAME,
MEDIA_TYPE,
- Media.TYPE_VIDEO,
+ CustomMedia.TYPE_VIDEO,
CHUNK_SIZE,
chunk_count * CHUNK_SIZE), null);
@@ -663,10 +663,10 @@ public class MediaDatabase {
return times;
}
- public synchronized Media getMedia(String location) {
+ public synchronized CustomMedia getMedia(String location) {
Cursor cursor;
- Media media = null;
+ CustomMedia media = null;
try {
cursor = mDb.query(
@@ -695,7 +695,7 @@ public class MediaDatabase {
return null;
}
if (cursor.moveToFirst()) {
- media = new Media(location,
+ media = new CustomMedia(location,
cursor.getLong(0),
cursor.getLong(1),
cursor.getInt(2),
@@ -939,7 +939,7 @@ public class MediaDatabase {
mDb.delete(MEDIA_TABLE_NAME, null, null);
}
- public static void setPicture(Media m, Bitmap p) {
+ public static void setPicture(CustomMedia m, Bitmap p) {
Log.d(TAG, "Setting new picture for " + m.getTitle());
try {
getInstance().updateMedia(
diff --git a/vlc-android/src/org/videolan/vlc/MediaGroup.java b/vlc-android/src/org/videolan/vlc/MediaGroup.java
index df5ef5d..25ab5de 100644
--- a/vlc-android/src/org/videolan/vlc/MediaGroup.java
+++ b/vlc-android/src/org/videolan/vlc/MediaGroup.java
@@ -23,24 +23,24 @@ package org.videolan.vlc;
import java.util.ArrayList;
import java.util.List;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.util.BitmapUtil;
-public class MediaGroup extends Media {
+public class MediaGroup extends CustomMedia {
public final static String TAG = "VLC/MediaGroup";
public final static int MIN_GROUP_LENGTH = 5;
- private Media mMedia;
- private ArrayList<Media> mMedias;
+ private CustomMedia mMedia;
+ private ArrayList<CustomMedia> mMedias;
- public MediaGroup(Media media)
+ public MediaGroup(CustomMedia media)
{
super(media.getLocation(),
media.getTime(),
media.getLength(),
- Media.TYPE_GROUP,
+ CustomMedia.TYPE_GROUP,
BitmapUtil.getPictureFromCache(media),
media.getTitle(),
media.getArtist(),
@@ -54,18 +54,18 @@ public class MediaGroup extends Media {
media.getSpuTrack(),
media.getTrackNumber());
mMedia = media;
- mMedias = new ArrayList<Media>();
+ mMedias = new ArrayList<CustomMedia>();
}
- public void add(Media media) {
+ public void add(CustomMedia media) {
mMedias.add(media);
}
- public Media getMedia() {
+ public CustomMedia getMedia() {
return size() == 0 ? mMedia : this;
}
- public Media getFirstMedia() {
+ public CustomMedia getFirstMedia() {
return size() == 0 ? mMedia : mMedias.get(0);
}
@@ -73,7 +73,7 @@ public class MediaGroup extends Media {
return mMedias.size();
}
- public void merge(Media media, String title) {
+ public void merge(CustomMedia media, String title) {
if (size() == 0) {
if (mMedia != null)
mMedias.add(mMedia);
@@ -83,14 +83,14 @@ public class MediaGroup extends Media {
this.mTitle = title;
}
- public static List<MediaGroup> group(List<Media> mediaList) {
+ public static List<MediaGroup> group(List<CustomMedia> mediaList) {
ArrayList<MediaGroup> groups = new ArrayList<MediaGroup>();
- for (Media media : mediaList)
+ for (CustomMedia media : mediaList)
insertInto(groups, media);
return groups;
}
- private static void insertInto(ArrayList<MediaGroup> groups, Media media)
+ private static void insertInto(ArrayList<MediaGroup> groups, CustomMedia media)
{
for (MediaGroup mediaGroup : groups) {
CharSequence group = mediaGroup.getTitle();
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index 4a495bd..f800a6e 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -35,7 +35,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.audio.AudioBrowserFragment;
import org.videolan.vlc.util.AndroidDevices;
@@ -55,7 +55,7 @@ public class MediaLibrary {
public static final int MEDIA_ITEMS_UPDATED = 100;
private static MediaLibrary mInstance;
- private final ArrayList<Media> mItemList;
+ private final ArrayList<CustomMedia> mItemList;
private final ArrayList<Handler> mUpdateHandler;
private final ReadWriteLock mItemListLock;
private boolean isStopping = false;
@@ -64,7 +64,7 @@ public class MediaLibrary {
private MediaLibrary() {
mInstance = this;
- mItemList = new ArrayList<Media>();
+ mItemList = new ArrayList<CustomMedia>();
mUpdateHandler = new ArrayList<Handler>();
mItemListLock = new ReentrantReadWriteLock();
}
@@ -115,8 +115,8 @@ public class MediaLibrary {
mUpdateHandler.remove(handler);
}
- public ArrayList<Media> searchMedia(String query, int type){
- ArrayList<Media> mediaList = new ArrayList<Media>();
+ public ArrayList<CustomMedia> searchMedia(String query, int type){
+ ArrayList<CustomMedia> mediaList = new ArrayList<CustomMedia>();
ArrayList<String> pathList = MediaDatabase.getInstance().searchMedia(query, type);
if (!pathList.isEmpty()){
for (String path : pathList) {
@@ -126,12 +126,12 @@ public class MediaLibrary {
return mediaList;
}
- public ArrayList<Media> getVideoItems() {
- ArrayList<Media> videoItems = new ArrayList<Media>();
+ public ArrayList<CustomMedia> getVideoItems() {
+ ArrayList<CustomMedia> videoItems = new ArrayList<CustomMedia>();
mItemListLock.readLock().lock();
for (int i = 0; i < mItemList.size(); i++) {
- Media item = mItemList.get(i);
- if (item != null && item.getType() == Media.TYPE_VIDEO) {
+ CustomMedia item = mItemList.get(i);
+ if (item != null && item.getType() == CustomMedia.TYPE_VIDEO) {
videoItems.add(item);
}
}
@@ -139,12 +139,12 @@ public class MediaLibrary {
return videoItems;
}
- public ArrayList<Media> getAudioItems() {
- ArrayList<Media> audioItems = new ArrayList<Media>();
+ public ArrayList<CustomMedia> getAudioItems() {
+ ArrayList<CustomMedia> audioItems = new ArrayList<CustomMedia>();
mItemListLock.readLock().lock();
for (int i = 0; i < mItemList.size(); i++) {
- Media item = mItemList.get(i);
- if (item.getType() == Media.TYPE_AUDIO) {
+ CustomMedia item = mItemList.get(i);
+ if (item.getType() == CustomMedia.TYPE_AUDIO) {
audioItems.add(item);
}
}
@@ -152,12 +152,12 @@ public class MediaLibrary {
return audioItems;
}
- public ArrayList<Media> getAudioItems(String name, String name2, int mode) {
- ArrayList<Media> audioItems = new ArrayList<Media>();
+ public ArrayList<CustomMedia> getAudioItems(String name, String name2, int mode) {
+ ArrayList<CustomMedia> audioItems = new ArrayList<CustomMedia>();
mItemListLock.readLock().lock();
for (int i = 0; i < mItemList.size(); i++) {
- Media item = mItemList.get(i);
- if (item.getType() == Media.TYPE_AUDIO) {
+ CustomMedia item = mItemList.get(i);
+ if (item.getType() == CustomMedia.TYPE_AUDIO) {
boolean valid = false;
switch (mode) {
@@ -182,14 +182,14 @@ public class MediaLibrary {
return audioItems;
}
- public ArrayList<Media> getMediaItems() {
+ public ArrayList<CustomMedia> getMediaItems() {
return mItemList;
}
- public Media getMediaItem(String location) {
+ public CustomMedia getMediaItem(String location) {
mItemListLock.readLock().lock();
for (int i = 0; i < mItemList.size(); i++) {
- Media item = mItemList.get(i);
+ CustomMedia item = mItemList.get(i);
if (item.getLocation().equals(location)) {
mItemListLock.readLock().unlock();
return item;
@@ -199,10 +199,10 @@ public class MediaLibrary {
return null;
}
- public ArrayList<Media> getMediaItems(List<String> pathList) {
- ArrayList<Media> items = new ArrayList<Media>();
+ public ArrayList<CustomMedia> getMediaItems(List<String> pathList) {
+ ArrayList<CustomMedia> items = new ArrayList<CustomMedia>();
for (int i = 0; i < pathList.size(); i++) {
- Media item = getMediaItem(pathList.get(i));
+ CustomMedia item = getMediaItem(pathList.get(i));
items.add(item);
}
return items;
@@ -245,7 +245,7 @@ public class MediaLibrary {
directories.addAll(mediaDirs);
// get all existing media items
- HashMap<String, Media> existingMedias = DBManager.getMedias();
+ HashMap<String, CustomMedia> existingMedias = DBManager.getMedias();
// list of all added files
HashSet<String> addedLocations = new HashSet<String>();
@@ -331,7 +331,7 @@ public class MediaLibrary {
} else {
mItemListLock.writeLock().lock();
// create new media item
- Media m = new Media(libVlcInstance, fileURI);
+ CustomMedia m = new CustomMedia(libVlcInstance, fileURI);
mItemList.add(m);
// Add this item to database
MediaDatabase db = MediaDatabase.getInstance();
@@ -401,15 +401,15 @@ public class MediaLibrary {
public boolean accept(File f) {
boolean accepted = false;
if (!f.isHidden()) {
- if (f.isDirectory() && !Media.FOLDER_BLACKLIST.contains(f.getPath().toLowerCase(Locale.ENGLISH))) {
+ if (f.isDirectory() && !CustomMedia.FOLDER_BLACKLIST.contains(f.getPath().toLowerCase(Locale.ENGLISH))) {
accepted = true;
} else {
String fileName = f.getName().toLowerCase(Locale.ENGLISH);
int dotIndex = fileName.lastIndexOf(".");
if (dotIndex != -1) {
String fileExt = fileName.substring(dotIndex);
- accepted = Media.AUDIO_EXTENSIONS.contains(fileExt) ||
- Media.VIDEO_EXTENSIONS.contains(fileExt);
+ accepted = CustomMedia.AUDIO_EXTENSIONS.contains(fileExt) ||
+ CustomMedia.VIDEO_EXTENSIONS.contains(fileExt);
}
}
}
diff --git a/vlc-android/src/org/videolan/vlc/Thumbnailer.java b/vlc-android/src/org/videolan/vlc/Thumbnailer.java
index 22280d6..477dc5c 100644
--- a/vlc-android/src/org/videolan/vlc/Thumbnailer.java
+++ b/vlc-android/src/org/videolan/vlc/Thumbnailer.java
@@ -31,7 +31,7 @@ import java.util.concurrent.locks.ReentrantLock;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.gui.video.VideoBrowserInterface;
import org.videolan.vlc.util.BitmapUtil;
import org.videolan.vlc.util.VLCInstance;
@@ -48,7 +48,7 @@ public class Thumbnailer implements Runnable {
private VideoBrowserInterface mVideoBrowser;
- private final Queue<Media> mItems = new LinkedList<Media>();
+ private final Queue<CustomMedia> mItems = new LinkedList<CustomMedia>();
private boolean isStopping = false;
private final Lock lock = new ReentrantLock();
@@ -114,7 +114,7 @@ public class Thumbnailer implements Runnable {
* Add a new id of the file browser item to create its thumbnail.
* @param id the if of the file browser item.
*/
- public void addJob(Media item) {
+ public void addJob(CustomMedia item) {
if(BitmapUtil.getPictureFromCache(item) != null || item.isPictureParsed())
return;
lock.lock();
@@ -160,7 +160,7 @@ public class Thumbnailer implements Runnable {
break;
}
total = totalCount;
- Media item = mItems.poll();
+ CustomMedia item = mItems.poll();
lock.unlock();
if (mVideoBrowser != null) {
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index f74e2b8..70ccdac 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -42,7 +42,7 @@ import org.videolan.libvlc.EventHandler;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.libvlc.CustomMediaList;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.R;
@@ -469,7 +469,7 @@ public class AudioService extends Service {
String location = service.mLibVLC.getMediaList().getMRL(service.mCurrentIndex);
long length = service.mLibVLC.getLength();
MediaDatabase dbManager = MediaDatabase.getInstance();
- Media m = dbManager.getMedia(location);
+ CustomMedia m = dbManager.getMedia(location);
/**
* 1) There is a media to update
* 2) It has a length of 0
@@ -678,7 +678,7 @@ public class AudioService extends Service {
*
* @return The current media or null if there is not any.
*/
- private Media getCurrentMedia() {
+ private CustomMedia getCurrentMedia() {
return mLibVLC.getMediaList().getMedia(mCurrentIndex);
}
@@ -724,7 +724,7 @@ public class AudioService extends Service {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void showNotification() {
try {
- Media media = getCurrentMedia();
+ CustomMedia media = getCurrentMedia();
if (media == null)
return;
Bitmap cover = AudioUtil.getCover(this, media, 64);
@@ -941,7 +941,7 @@ public class AudioService extends Service {
if (!LibVlcUtil.isICSOrLater()) // NOP check
return;
- Media media = getCurrentMedia();
+ CustomMedia media = getCurrentMedia();
if (mRemoteControlClient != null && media != null) {
MetadataEditor editor = mRemoteControlClient.editMetadata(true);
if (media.getNowPlaying() != null) {
@@ -1009,7 +1009,7 @@ public class AudioService extends Service {
}
private Bitmap getCover() {
- Media media = getCurrentMedia();
+ CustomMedia media = getCurrentMedia();
return media != null ? AudioUtil.getCover(this, media, 512) : null;
}
@@ -1191,7 +1191,7 @@ public class AudioService extends Service {
MediaDatabase db = MediaDatabase.getInstance();
for (int i = 0; i < mediaPathList.size(); i++) {
String location = mediaPathList.get(i);
- Media media = db.getMedia(location);
+ CustomMedia media = db.getMedia(location);
if(media == null) {
if(!validateLocation(location)) {
Log.w(TAG, "Invalid location " + location);
@@ -1199,7 +1199,7 @@ public class AudioService extends Service {
continue;
}
Log.v(TAG, "Creating on-the-fly Media object for " + location);
- media = new Media(mLibVLC, location);
+ media = new CustomMedia(mLibVLC, location);
}
mediaList.add(media, noVideo);
}
@@ -1296,14 +1296,14 @@ public class AudioService extends Service {
MediaDatabase db = MediaDatabase.getInstance();
for (int i = 0; i < mediaLocationList.size(); i++) {
String location = mediaLocationList.get(i);
- Media media = db.getMedia(location);
+ CustomMedia media = db.getMedia(location);
if(media == null) {
if (!validateLocation(location)) {
showToast(getResources().getString(R.string.invalid_location, location), Toast.LENGTH_SHORT);
continue;
}
Log.v(TAG, "Creating on-the-fly Media object for " + location);
- media = new Media(mLibVLC, location);
+ media = new CustomMedia(mLibVLC, location);
}
mLibVLC.getMediaList().add(media);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
index 50d96a4..88d8563 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserActivity.java
@@ -27,7 +27,7 @@ import java.util.Arrays;
import java.util.Locale;
import java.util.Stack;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.R;
import org.videolan.vlc.util.AndroidDevices;
@@ -284,7 +284,7 @@ public class BrowserActivity extends ListActivity {
@Override
public boolean accept(File f) {
- return f.isDirectory() && !Media.FOLDER_BLACKLIST.contains(f.getPath().toLowerCase(Locale.ENGLISH));
+ return f.isDirectory() && !CustomMedia.FOLDER_BLACKLIST.contains(f.getPath().toLowerCase(Locale.ENGLISH));
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
index 3c1ed56..5d98669 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
@@ -29,7 +29,7 @@ import java.util.ListIterator;
import java.util.regex.Pattern;
import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.util.AndroidDevices;
@@ -56,7 +56,7 @@ public class DirectoryAdapter extends BaseAdapter {
private ContextPopupMenuListener mContextPopupMenuListener;
public static boolean acceptedPath(String f) {
- return Pattern.compile(Media.EXTENSIONS_REGEX, Pattern.CASE_INSENSITIVE).matcher(f).matches();
+ return Pattern.compile(CustomMedia.EXTENSIONS_REGEX, Pattern.CASE_INSENSITIVE).matcher(f).matches();
}
/**
@@ -327,7 +327,7 @@ public class DirectoryAdapter extends BaseAdapter {
String holderText = "";
if(selectedNode.isFile()) {
Log.d(TAG, "Loading media " + selectedNode.name);
- Media m = new Media(LibVLC.getExistingInstance(), getMediaLocation(position));
+ CustomMedia m = new CustomMedia(LibVLC.getExistingInstance(), getMediaLocation(position));
holder.title.setText(m.getTitle());
holderText = m.getSubtitle();
} else
diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
index f24577c..b9f59f8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
@@ -23,7 +23,7 @@ package org.videolan.vlc.gui;
import org.videolan.libvlc.EventHandler;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.audio.AudioUtil;
@@ -93,7 +93,7 @@ public class HistoryAdapter extends BaseAdapter {
holder = (DirectoryAdapter.DirectoryViewHolder) v.getTag();
String holderText = "";
- Media m = mLibVLC.getPrimaryMediaList().getMedia(position);
+ CustomMedia m = mLibVLC.getPrimaryMediaList().getMedia(position);
if (m == null )
return v;
diff --git a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
index da8c950..e33cc95 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
@@ -22,7 +22,7 @@ package org.videolan.vlc.gui;
import java.util.ArrayList;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
@@ -105,7 +105,7 @@ public class SearchFragment extends ListFragment {
mResultAdapter.clear();
new Thread(new Runnable() {
public void run() {
- final ArrayList<Media> mediaList = MediaLibrary.getInstance().searchMedia(key, type);
+ final ArrayList<CustomMedia> mediaList = MediaLibrary.getInstance().searchMedia(key, type);
mHandler.post(new Runnable() {
public void run() {
int count = mediaList.size();
@@ -158,7 +158,7 @@ public class SearchFragment extends ListFragment {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 0) {
- search(s.toString(), Media.TYPE_ALL);
+ search(s.toString(), CustomMedia.TYPE_ALL);
} else {
showSearchHistory();
}
@@ -198,15 +198,15 @@ public class SearchFragment extends ListFragment {
db.addSearchhistoryItem(mSearchText.getText().toString());
// open media in the player
- Media item = (Media) getListView().getItemAtPosition(position);
+ CustomMedia item = (CustomMedia) getListView().getItemAtPosition(position);
if (item != null) {
- if (item.getType() == Media.TYPE_VIDEO) {
+ if (item.getType() == CustomMedia.TYPE_VIDEO) {
VideoPlayerActivity.start(getActivity(), item.getLocation());
} else {
ArrayList<String> arr = new ArrayList<String>();
for (int i = 0; i < getListAdapter().getCount(); i++) {
- Media audioItem = (Media) getListAdapter().getItem(i);
- if (audioItem.getType() == Media.TYPE_AUDIO)
+ CustomMedia audioItem = (CustomMedia) getListAdapter().getItem(i);
+ if (audioItem.getType() == CustomMedia.TYPE_AUDIO)
arr.add(audioItem.getLocation());
}
AudioServiceController.getInstance().load(arr, arr.indexOf(item.getLocation()));
diff --git a/vlc-android/src/org/videolan/vlc/gui/SearchResultAdapter.java b/vlc-android/src/org/videolan/vlc/gui/SearchResultAdapter.java
index 6eb7a36..9730246 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SearchResultAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SearchResultAdapter.java
@@ -22,7 +22,7 @@ package org.videolan.vlc.gui;
import java.util.Comparator;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import android.content.Context;
import android.view.LayoutInflater;
@@ -31,8 +31,8 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
-public class SearchResultAdapter extends ArrayAdapter<Media>
- implements Comparator<Media> {
+public class SearchResultAdapter extends ArrayAdapter<CustomMedia>
+ implements Comparator<CustomMedia> {
public SearchResultAdapter(Context context) {
super(context, 0);
@@ -51,14 +51,14 @@ public class SearchResultAdapter extends ArrayAdapter<Media>
} else
holder = (ViewHolder) view.getTag();
- Media item = getItem(position);
+ CustomMedia item = getItem(position);
holder.text.setText(item.getTitle());
return view;
}
@Override
- public int compare(Media object1, Media object2) {
+ public int compare(CustomMedia object1, CustomMedia object2) {
return object1.getTitle().compareToIgnoreCase(object2.getTitle());
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index d4df1d5..cc6d706 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -25,7 +25,7 @@ import java.util.Collections;
import java.util.List;
import org.videolan.libvlc.LibVlcUtil;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
import org.videolan.vlc.audio.AudioServiceController;
@@ -80,7 +80,7 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
public final static String EXTRA_NAME2 = "name2";
public final static String EXTRA_MODE = "mode";
- private ArrayList<Media> mediaList;
+ private ArrayList<CustomMedia> mediaList;
private String mTitle;
TabHost mTabHost;
@@ -90,7 +90,7 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
/* All subclasses of Fragment must include a public empty constructor. */
public AudioAlbumsSongsFragment() { }
- public void setMediaList(ArrayList<Media> mediaList, String title) {
+ public void setMediaList(ArrayList<CustomMedia> mediaList, String title) {
this.mediaList = mediaList;
mTitle = title;
}
@@ -295,7 +295,7 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
@Override
public void run(Object o) {
AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
- Media media = listItem.mMediaList.get(0);
+ CustomMedia media = listItem.mMediaList.get(0);
mMediaLibrary.getMediaItems().remove(media);
mSongsAdapter.removeMedia(media);
mAlbumsAdapter.removeMedia(media);
@@ -354,7 +354,7 @@ public class AudioAlbumsSongsFragment extends Fragment implements SwipeRefreshLa
@Override
public void run() {
for (int i = 0; i < mediaList.size(); ++i) {
- Media media = mediaList.get(i);
+ CustomMedia media = mediaList.get(i);
mAlbumsAdapter.addSeparator(media.getReferenceArtist(), media);
mAlbumsAdapter.add(media.getAlbum(), null, media);
mSongsAdapter.addSeparator(media.getAlbum(), media);
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 55cf342..c2124a1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -52,7 +52,7 @@ import android.widget.PopupMenu.OnMenuItemClickListener;
import android.widget.ProgressBar;
import org.videolan.libvlc.LibVlcUtil;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
import org.videolan.vlc.audio.AudioServiceController;
@@ -296,7 +296,7 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
OnItemClickListener artistListListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> av, View v, int p, long id) {
- ArrayList<Media> mediaList = mArtistsAdapter.getMedia(p);
+ ArrayList<CustomMedia> mediaList = mArtistsAdapter.getMedia(p);
MainActivity activity = (MainActivity)getActivity();
AudioAlbumsSongsFragment frag = (AudioAlbumsSongsFragment)activity.showSecondaryFragment("albumsSongs");
if (frag != null) {
@@ -316,7 +316,7 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
OnItemClickListener genreListListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> av, View v, int p, long id) {
- ArrayList<Media> mediaList = mGenresAdapter.getMedia(p);
+ ArrayList<CustomMedia> mediaList = mGenresAdapter.getMedia(p);
MainActivity activity = (MainActivity)getActivity();
AudioAlbumsSongsFragment frag = (AudioAlbumsSongsFragment)activity.showSecondaryFragment("albumsSongs");
if (frag != null) {
@@ -383,7 +383,7 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
@Override
public void run(Object o) {
AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem)o;
- Media media = listItem.mMediaList.get(0);
+ CustomMedia media = listItem.mMediaList.get(0);
mMediaLibrary.getMediaItems().remove(media);
mAudioController.removeLocation(media.getLocation());
updateLists();
@@ -539,7 +539,7 @@ public class AudioBrowserFragment extends Fragment implements SwipeRefreshLayout
mArtistsAdapter.clear();
mAlbumsAdapter.clear();
mGenresAdapter.clear();
- final List<Media> audioList = MediaLibrary.getInstance().getAudioItems();
+ final List<CustomMedia> audioList = MediaLibrary.getInstance().getAudioItems();
if (audioList.isEmpty()){
mSwipeRefreshLayout.setRefreshing(false);
mEmptyView.setVisibility(View.VISIBLE);
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index 16fdc2c..251e61d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -28,7 +28,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.R;
import org.videolan.vlc.util.BitmapCache;
import org.videolan.vlc.util.Util;
@@ -84,11 +84,11 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
class ListItem {
public String mTitle;
public String mSubTitle;
- public ArrayList<Media> mMediaList;
+ public ArrayList<CustomMedia> mMediaList;
public boolean mIsSeparator;
- public ListItem(String title, String subTitle, Media media, boolean isSeparator) {
- mMediaList = new ArrayList<Media>();
+ public ListItem(String title, String subTitle, CustomMedia media, boolean isSeparator) {
+ mMediaList = new ArrayList<CustomMedia>();
if (media != null)
mMediaList.add(media);
mTitle = title;
@@ -110,7 +110,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
mAlignMode = Integer.valueOf(preferences.getString("audio_title_alignment", "0"));
}
- public void add(String title, String subTitle, Media media) {
+ public void add(String title, String subTitle, CustomMedia media) {
if(title == null) return;
title = title.trim();
if(subTitle != null) subTitle = subTitle.trim();
@@ -123,13 +123,13 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
}
}
- public void addAll(List<Media> mediaList, final int type) {
- final LinkedList<Media> list = new LinkedList<Media>(mediaList);
+ public void addAll(List<CustomMedia> mediaList, final int type) {
+ final LinkedList<CustomMedia> list = new LinkedList<CustomMedia>(mediaList);
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
String title, subTitle;
- for (Media media : list) {
+ for (CustomMedia media : list) {
switch (type){
case TYPE_ALBUMS:
title = media.getAlbum();
@@ -216,7 +216,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
}
}
- public void addSeparator(String title, Media media) {
+ public void addSeparator(String title, CustomMedia media) {
if(title == null) return;
title = title.trim();
if (mSeparatorItemMap.containsKey(title))
@@ -233,7 +233,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
for (ListItem album : mSeparatorItemMap.values()){
mItems.add(album);
Collections.sort(album.mMediaList, MediaComparators.byTrackNumber);
- for (Media media : album.mMediaList)
+ for (CustomMedia media : album.mMediaList)
add(media.getTitle(), null, media);
}
}
@@ -243,7 +243,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
* Remove also all the list items that contain only this media.
* @param media the media to remove
*/
- public void removeMedia(Media media) {
+ public void removeMedia(CustomMedia media) {
for (int i = 0; i < mItems.size(); ++i) {
ListItem item = mItems.get(i);
if (item.mMediaList == null)
@@ -311,7 +311,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
RelativeLayout.LayoutParams paramsCover;
if (mItemType == ITEM_WITH_COVER) {
- Media media = mItems.get(position).mMediaList.get(0);
+ CustomMedia media = mItems.get(position).mMediaList.get(0);
Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64);
if (cover == null)
cover = BitmapCache.GetFromResource(v, R.drawable.icon);
@@ -461,9 +461,9 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
return sections.toArray();
}
- public ArrayList<Media> getMedia(int position) {
+ public ArrayList<CustomMedia> getMedia(int position) {
// Return all the media of a list item list.
- ArrayList<Media> mediaList = new ArrayList<Media>();
+ ArrayList<CustomMedia> mediaList = new ArrayList<CustomMedia>();
if (!mItems.get(position).mIsSeparator)
mediaList.addAll(mItems.get(position).mMediaList);
return mediaList;
@@ -477,7 +477,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
// Return all the media locations of a list item list.
ArrayList<String> locations = new ArrayList<String>();
if (isEnabled(position)) {
- ArrayList<Media> mediaList = mItems.get(position).mMediaList;
+ ArrayList<CustomMedia> mediaList = mItems.get(position).mMediaList;
if (sortByTrackNumber)
Collections.sort(mediaList, MediaComparators.byTrackNumber);
for (int i = 0; i < mediaList.size(); ++i)
@@ -502,7 +502,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
if(position == i && !mItems.get(i).mMediaList.isEmpty())
outputPosition = outputList.size();
- for(Media k : mItems.get(i).mMediaList) {
+ for(CustomMedia k : mItems.get(i).mMediaList) {
outputList.add(k.getLocation());
}
}
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 f24fabc..9f3f0e6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -26,7 +26,7 @@ import android.content.Context;
import android.content.Intent;
import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.R;
import org.videolan.vlc.audio.AudioServiceController;
import org.videolan.vlc.audio.RepeatType;
@@ -383,7 +383,7 @@ public class AudioPlayer extends Fragment implements IAudioPlayer {
}
private void updateList() {
- ArrayList<Media> audioList = new ArrayList<Media>();
+ ArrayList<CustomMedia> audioList = new ArrayList<CustomMedia>();
String currentItem = null;
int currentIndex = -1;
@@ -396,7 +396,7 @@ public class AudioPlayer extends Fragment implements IAudioPlayer {
mSongsListAdapter.clear();
for (int i = 0; i < audioList.size(); i++) {
- Media media = audioList.get(i);
+ CustomMedia media = audioList.get(i);
if (currentItem != null && currentItem.equals(media.getLocation()))
currentIndex = i;
mSongsListAdapter.add(media);
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
index d85efae..9f8230a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistAdapter.java
@@ -23,7 +23,7 @@ package org.videolan.vlc.gui.audio;
import java.util.ArrayList;
import java.util.List;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.R;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.widget.AudioPlaylistItemViewGroup;
@@ -44,9 +44,9 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
-public class AudioPlaylistAdapter extends ArrayAdapter<Media> {
+public class AudioPlaylistAdapter extends ArrayAdapter<CustomMedia> {
- private ArrayList<Media> mMediaList;
+ private ArrayList<CustomMedia> mMediaList;
private int mCurrentIndex;
private Context mContext;
private int mAlignMode;
@@ -54,20 +54,20 @@ public class AudioPlaylistAdapter extends ArrayAdapter<Media> {
public AudioPlaylistAdapter(Context context) {
super(context, 0);
mContext = context;
- mMediaList = new ArrayList<Media>();
+ mMediaList = new ArrayList<CustomMedia>();
mCurrentIndex = -1;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
mAlignMode = Integer.valueOf(preferences.getString("audio_title_alignment", "0"));
}
@Override
- public void add(Media m) {
+ public void add(CustomMedia m) {
mMediaList.add(m);
super.add(m);
}
@Override
- public void remove(Media m) {
+ public void remove(CustomMedia m) {
mMediaList.remove(m);
super.remove(m);
}
@@ -107,7 +107,7 @@ public class AudioPlaylistAdapter extends ArrayAdapter<Media> {
holder.layoutFooter.setVisibility(LinearLayout.VISIBLE);
holder.itemGroup.scrollTo(1);
- Media media = getItem(position);
+ CustomMedia media = getItem(position);
final String title = media.getTitle();
final String artist = media.getSubtitle();
final int pos = position;
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
index e5a3e9b..db48b7f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioUtil.java
@@ -31,7 +31,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import org.videolan.libvlc.LibVlcUtil;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.util.AndroidDevices;
@@ -74,7 +74,7 @@ public class AudioUtil {
*/
public static String PLAYLIST_DIR = null;
- public static void setRingtone(Media song, Context context){
+ public static void setRingtone(CustomMedia song, Context context){
File newringtone = LibVlcUtil.URItoFile(song.getLocation());
if(newringtone == null || (newringtone != null && !newringtone.exists())) {
Toast.makeText(context.getApplicationContext(),context.getString(R.string.ringtone_error), Toast.LENGTH_SHORT).show();
@@ -152,7 +152,7 @@ public class AudioUtil {
dir.delete();
}
- private static String getCoverFromMediaStore(Context context, Media media) {
+ private static String getCoverFromMediaStore(Context context, CustomMedia media) {
ContentResolver contentResolver = context.getContentResolver();
Uri uri = android.provider.MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;
Cursor cursor = contentResolver.query(uri, new String[] {
@@ -174,7 +174,7 @@ public class AudioUtil {
return null;
}
- private static String getCoverFromVlc(Context context, Media media) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+ private static String getCoverFromVlc(Context context, CustomMedia media) throws NoSuchAlgorithmException, UnsupportedEncodingException {
String artworkURL = media.getArtworkURL();
if (artworkURL != null && artworkURL.startsWith("file://")) {
return Uri.decode(artworkURL).replace("file://", "");
@@ -209,7 +209,7 @@ public class AudioUtil {
return null;
}
- private static String getCoverFromFolder(Context context, Media media) {
+ private static String getCoverFromFolder(Context context, CustomMedia media) {
File f = LibVlcUtil.URItoFile(media.getLocation());
if (f != null && f.getParentFile() != null && f.getParentFile().listFiles() != null)
for (File s : f.getParentFile().listFiles()) {
@@ -221,7 +221,7 @@ public class AudioUtil {
}
@SuppressLint("NewApi")
- public synchronized static Bitmap getCover(Context context, Media media, int width) {
+ public synchronized static Bitmap getCover(Context context, CustomMedia media, int width) {
String coverPath = null;
Bitmap cover = null;
String cachePath = null;
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java b/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java
index d0da1ed..e8be629 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/MediaComparators.java
@@ -21,36 +21,36 @@ package org.videolan.vlc.gui.audio;
import java.util.Comparator;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
public class MediaComparators {
- public static final Comparator<Media> byName = new Comparator<Media>() {
+ public static final Comparator<CustomMedia> byName = new Comparator<CustomMedia>() {
@Override
- public int compare(Media m1, Media m2) {
+ public int compare(CustomMedia m1, CustomMedia m2) {
return String.CASE_INSENSITIVE_ORDER.compare(m1.getTitle(), m2.getTitle());
};
};
- public static final Comparator<Media> byMRL = new Comparator<Media>() {
+ public static final Comparator<CustomMedia> byMRL = new Comparator<CustomMedia>() {
@Override
- public int compare(Media m1, Media m2) {
+ public int compare(CustomMedia m1, CustomMedia m2) {
return String.CASE_INSENSITIVE_ORDER.compare(m1.getLocation(), m2.getLocation());
};
};
- public static final Comparator<Media> byLength = new Comparator<Media>() {
+ public static final Comparator<CustomMedia> byLength = new Comparator<CustomMedia>() {
@Override
- public int compare(Media m1, Media m2) {
+ public int compare(CustomMedia m1, CustomMedia m2) {
if(m1.getLength() > m2.getLength()) return -1;
if(m1.getLength() < m2.getLength()) return 1;
else return 0;
};
};
- public static final Comparator<Media> byAlbum = new Comparator<Media>() {
+ public static final Comparator<CustomMedia> byAlbum = new Comparator<CustomMedia>() {
@Override
- public int compare(Media m1, Media m2) {
+ public int compare(CustomMedia m1, CustomMedia m2) {
int res = String.CASE_INSENSITIVE_ORDER.compare(m1.getAlbum(), m2.getAlbum());
if (res == 0)
res = byMRL.compare(m1, m2);
@@ -58,9 +58,9 @@ public class MediaComparators {
};
};
- public static final Comparator<Media> byArtist = new Comparator<Media>() {
+ public static final Comparator<CustomMedia> byArtist = new Comparator<CustomMedia>() {
@Override
- public int compare(Media m1, Media m2) {
+ public int compare(CustomMedia m1, CustomMedia m2) {
int res = String.CASE_INSENSITIVE_ORDER.compare(m1.getReferenceArtist(), m2.getReferenceArtist());
if (res == 0)
res = byAlbum.compare(m1, m2);
@@ -68,9 +68,9 @@ public class MediaComparators {
};
};
- public static final Comparator<Media> byGenre = new Comparator<Media>() {
+ public static final Comparator<CustomMedia> byGenre = new Comparator<CustomMedia>() {
@Override
- public int compare(Media m1, Media m2) {
+ public int compare(CustomMedia m1, CustomMedia m2) {
int res = String.CASE_INSENSITIVE_ORDER.compare(m1.getGenre(), m2.getGenre());
if (res == 0)
res = byArtist.compare(m1, m2);
@@ -78,9 +78,9 @@ public class MediaComparators {
};
};
- public static final Comparator<Media> byTrackNumber = new Comparator<Media>() {
+ public static final Comparator<CustomMedia> byTrackNumber = new Comparator<CustomMedia>() {
@Override
- public int compare(Media m1, Media m2) {
+ public int compare(CustomMedia m1, CustomMedia m2) {
if(m1.getTrackNumber() < m2.getTrackNumber()) return -1;
if(m1.getTrackNumber() > m2.getTrackNumber()) return 1;
else return 0;
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 d234b14..537eb9c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -24,7 +24,7 @@ import java.nio.ByteBuffer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.libvlc.TrackInfo;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
@@ -54,7 +54,7 @@ import android.widget.TextView;
public class MediaInfoFragment extends ListFragment {
public final static String TAG = "VLC/MediaInfoFragment";
- private Media mItem;
+ private CustomMedia mItem;
private Bitmap mImage;
private TextView mLengthView;
private ImageButton mPlayButton;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserInterface.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserInterface.java
index 69219ab..184c089 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserInterface.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserInterface.java
@@ -2,7 +2,7 @@ package org.videolan.vlc.gui.video;
import java.util.concurrent.BrokenBarrierException;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
public interface VideoBrowserInterface {
public static final long HEADER_VIDEO = 0;
@@ -17,7 +17,7 @@ public interface VideoBrowserInterface {
public static final String AUDIO_FILTER = "filter";
public void resetBarrier();
- public void setItemToUpdate(Media item);
+ public void setItemToUpdate(CustomMedia item);
public void await() throws InterruptedException, BrokenBarrierException;
public void updateItem();
public void updateList();
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 1f091d5..30033df 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -29,7 +29,7 @@ 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.CustomMedia;
import org.videolan.libvlc.TrackInfo;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaGroup;
@@ -94,7 +94,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
protected LinearLayout mLayoutFlipperLoading;
protected GridView mGridView;
protected TextView mTextViewNomedia;
- protected Media mItemToUpdate;
+ protected CustomMedia mItemToUpdate;
protected String mGroup;
protected final CyclicBarrier mBarrier = new CyclicBarrier(2);
@@ -276,7 +276,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
@Override
public void onGridItemClick(GridView l, View v, int position, long id) {
- Media media = (Media) getListAdapter().getItem(position);
+ CustomMedia media = (CustomMedia) getListAdapter().getItem(position);
if (media instanceof MediaGroup) {
MainActivity activity = (MainActivity)getActivity();
VideoGridFragment frag = (VideoGridFragment)activity.showSecondaryFragment("videoGroupList");
@@ -289,16 +289,16 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
super.onGridItemClick(l, v, position, id);
}
- protected void playVideo(Media media, boolean fromStart) {
+ protected void playVideo(CustomMedia media, boolean fromStart) {
VideoPlayerActivity.start(getActivity(), media.getLocation(), fromStart);
}
- protected void playAudio(Media media) {
+ protected void playAudio(CustomMedia media) {
mAudioController.load(media.getLocation(), true);
}
private boolean handleContextItemSelected(MenuItem menu, int position) {
- Media media = mVideoAdapter.getItem(position);
+ CustomMedia media = mVideoAdapter.getItem(position);
switch (menu.getItemId())
{
case R.id.video_list_play_from_start:
@@ -321,7 +321,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
new VLCRunnable(media) {
@Override
public void run(Object o) {
- Media media = (Media) o;
+ CustomMedia media = (CustomMedia) o;
mMediaLibrary.getMediaItems().remove(media);
mVideoAdapter.remove(media);
mAudioController.removeLocation(media.getLocation());
@@ -337,7 +337,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
// Do not show the menu of media group.
AdapterContextMenuInfo info = (AdapterContextMenuInfo)menuInfo;
- Media media = mVideoAdapter.getItem(info.position);
+ CustomMedia media = mVideoAdapter.getItem(info.position);
if (media instanceof MediaGroup)
return;
MenuInflater inflater = getActivity().getMenuInflater();
@@ -345,7 +345,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
setContextMenuItems(menu, media);
}
- private void setContextMenuItems(Menu menu, Media media) {
+ private void setContextMenuItems(Menu menu, CustomMedia media) {
long lastTime = media.getTime();
if (lastTime > 0)
menu.findItem(R.id.video_list_play_from_start).setVisible(true);
@@ -379,7 +379,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu());
- Media media = mVideoAdapter.getItem(position);
+ CustomMedia media = mVideoAdapter.getItem(position);
setContextMenuItems(popupMenu.getMenu(), media);
popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
@@ -414,7 +414,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
public void updateList() {
if (!mSwipeRefreshLayout.isRefreshing())
mSwipeRefreshLayout.setRefreshing(true);
- final List<Media> itemList = mMediaLibrary.getVideoItems();
+ final List<CustomMedia> itemList = mMediaLibrary.getVideoItems();
if (mThumbnailer != null)
mThumbnailer.clearJobs();
@@ -430,7 +430,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
public void run() {
if (mGroup != null || itemList.size() <= 10) {
mVideoAdapter.setNotifyOnChange(false);
- for (Media item : itemList) {
+ for (CustomMedia item : itemList) {
if (mGroup == null || item.getTitle().startsWith(mGroup)) {
mVideoAdapter.add(item);
if (mThumbnailer != null)
@@ -481,7 +481,7 @@ public class VideoGridFragment extends SherlockGridFragment implements IBrowser,
mVideoAdapter.sortBy(sortby);
}
- public void setItemToUpdate(Media item) {
+ public void setItemToUpdate(CustomMedia item) {
mItemToUpdate = item;
mHandler.sendEmptyMessage(VideoListHandler.UPDATE_ITEM);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 269f2e5..bdc0258 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -24,7 +24,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaGroup;
import org.videolan.vlc.R;
import org.videolan.vlc.util.BitmapCache;
@@ -45,8 +45,8 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
-public class VideoListAdapter extends ArrayAdapter<Media>
- implements Comparator<Media> {
+public class VideoListAdapter extends ArrayAdapter<CustomMedia>
+ implements Comparator<CustomMedia> {
public final static int SORT_BY_TITLE = 0;
public final static int SORT_BY_LENGTH = 1;
@@ -64,7 +64,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
public final static String TAG = "VLC/MediaLibraryAdapter";
- public synchronized void update(Media item) {
+ public synchronized void update(CustomMedia item) {
int position = getPosition(item);
if (position != -1) {
remove(item);
@@ -75,7 +75,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
public void setTimes(HashMap<String, Long> times) {
// update times
for (int i = 0; i < getCount(); ++i) {
- Media media = getItem(i);
+ CustomMedia media = getItem(i);
Long time = times.get(media.getLocation());
if (time != null)
media.setTime(time);
@@ -113,7 +113,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
}
@Override
- public int compare(Media item1, Media item2) {
+ public int compare(CustomMedia item1, CustomMedia item2) {
int compare = 0;
switch (mSortBy) {
case SORT_BY_TITLE:
@@ -169,7 +169,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
}
});
- Media media = getItem(position);
+ CustomMedia media = getItem(position);
/* Thumbnail */
Bitmap thumbnail = BitmapUtil.getPictureFromCache(media);
@@ -197,7 +197,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
return v;
}
- private void fillGroupView(ViewHolder holder, Media media) {
+ private void fillGroupView(ViewHolder holder, CustomMedia media) {
MediaGroup mediaGroup = (MediaGroup) media;
int size = mediaGroup.size();
String text = getContext().getResources().getQuantityString(R.plurals.videos_quantity, size, size);
@@ -208,7 +208,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
holder.progress.setVisibility(View.INVISIBLE);
}
- private void fillVideoView(ViewHolder holder, Media media) {
+ private void fillVideoView(ViewHolder holder, CustomMedia media) {
/* Time / Duration */
if (media.getLength() > 0) {
long lastTime = media.getTime();
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 63736e2..b437c49 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -43,7 +43,7 @@ import org.videolan.libvlc.IVideoPlayer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
import org.videolan.libvlc.LibVlcUtil;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
@@ -2117,7 +2117,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
int time = (int) mLibVLC.getTime();
int length = (int) mLibVLC.getLength();
if (length == 0) {
- Media media = MediaDatabase.getInstance().getMedia(mLocation);
+ CustomMedia media = MediaDatabase.getInstance().getMedia(mLocation);
if (media != null)
length = (int) media.getLength();
}
@@ -2327,7 +2327,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
} else if (mLocation != null && mLocation.length() > 0 && !dontParse) {
AudioServiceController.getInstance().stop(); // Stop the previous playback.
mLibVLC.setMediaList();
- mLibVLC.getMediaList().add(new Media(mLibVLC, mLocation));
+ mLibVLC.getMediaList().add(new CustomMedia(mLibVLC, mLocation));
savedIndexPosition = mLibVLC.getMediaList().size() - 1;
mLibVLC.playIndex(savedIndexPosition);
}
@@ -2335,7 +2335,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
if (mLocation != null && mLocation.length() > 0 && !dontParse) {
// restore last position
- Media media = MediaDatabase.getInstance().getMedia(mLocation);
+ CustomMedia media = MediaDatabase.getInstance().getMedia(mLocation);
if(media != null) {
// in media library
if(media.getTime() > 0 && !fromStart)
diff --git a/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java b/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java
index 3a43dae..22ea493 100644
--- a/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java
+++ b/vlc-android/src/org/videolan/vlc/util/BitmapUtil.java
@@ -20,7 +20,7 @@
package org.videolan.vlc.util;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.VLCApplication;
@@ -79,7 +79,7 @@ public class BitmapUtil {
return bitmap;
}
- public static Bitmap getPictureFromCache(Media media)
+ public static Bitmap getPictureFromCache(CustomMedia media)
{
// mPicture is not null only if passed through
// the ctor which is deprecated by now.
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 48deee0..e9271a7 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -27,7 +27,7 @@ import java.io.InputStreamReader;
import java.util.concurrent.atomic.AtomicInteger;
import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.Media;
+import org.videolan.libvlc.CustomMedia;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.VLCCallbackTask;
@@ -95,10 +95,10 @@ public class Util {
* @param mrl MRL of the media
* @return A media object from the media library or newly created
*/
- public static Media getOrCreateMedia(LibVLC libVLC, String mrl) {
- Media mlItem = MediaLibrary.getInstance().getMediaItem(mrl);
+ public static CustomMedia getOrCreateMedia(LibVLC libVLC, String mrl) {
+ CustomMedia mlItem = MediaLibrary.getInstance().getMediaItem(mrl);
if(mlItem == null)
- mlItem = new Media(libVLC, mrl);
+ mlItem = new CustomMedia(libVLC, mrl);
return mlItem;
}
--
2.1.3
More information about the Android
mailing list