use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class MediaDatabase method getMedias.
public synchronized ArrayMap<String, MediaWrapper> getMedias() {
Cursor cursor;
ArrayMap<String, MediaWrapper> medias = new ArrayMap<String, MediaWrapper>();
int chunk_count = 0;
int count;
do {
count = 0;
cursor = mDb.rawQuery(String.format(Locale.US, "SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s LIMIT %d OFFSET %d", // 0 string
MEDIA_LOCATION, // 1 long
MEDIA_TIME, // 2 long
MEDIA_LENGTH, // 3 int
MEDIA_TYPE, // 4 string
MEDIA_TITLE, // 5 string
MEDIA_ARTIST, // 6 string
MEDIA_GENRE, // 7 string
MEDIA_ALBUM, // 8 string
MEDIA_ALBUMARTIST, // 9 int
MEDIA_WIDTH, // 10 int
MEDIA_HEIGHT, // 11 string
MEDIA_ARTWORKURL, // 12 int
MEDIA_AUDIOTRACK, // 13 int
MEDIA_SPUTRACK, // 14 int
MEDIA_TRACKNUMBER, // 15 int
MEDIA_DISCNUMBER, // 16 long
MEDIA_LAST_MODIFIED, MEDIA_TABLE_NAME, CHUNK_SIZE, chunk_count * CHUNK_SIZE), null);
if (cursor != null) {
if (cursor.moveToFirst()) {
try {
do {
final Uri uri = AndroidUtil.LocationToUri(cursor.getString(0));
MediaWrapper media = new MediaWrapper(uri, // MEDIA_TIME
cursor.getLong(1), // MEDIA_LENGTH
cursor.getLong(2), // MEDIA_TYPE
cursor.getInt(3), // MEDIA_PICTURE
null, // MEDIA_TITLE
cursor.getString(4), // MEDIA_ARTIST
cursor.getString(5), // MEDIA_GENRE
cursor.getString(6), // MEDIA_ALBUM
cursor.getString(7), // MEDIA_ALBUMARTIST
cursor.getString(8), // MEDIA_WIDTH
cursor.getInt(9), // MEDIA_HEIGHT
cursor.getInt(10), // MEDIA_ARTWORKURL
cursor.getString(11), // MEDIA_AUDIOTRACK
cursor.getInt(12), // MEDIA_SPUTRACK
cursor.getInt(13), // MEDIA_TRACKNUMBER
cursor.getInt(14), // MEDIA_DISCNUMBER
cursor.getInt(15), // MEDIA_LAST_MODIFIED
cursor.getLong(16), // MEDIA_SEEN
0L);
medias.put(media.getUri().toString(), media);
count++;
} while (cursor.moveToNext());
} catch (IllegalStateException e) {
}
// Google bug causing IllegalStateException, see https://code.google.com/p/android/issues/detail?id=32472
}
cursor.close();
}
chunk_count++;
} while (count == CHUNK_SIZE);
return medias;
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class MediaDatabase method getAllNetworkFav.
public synchronized List<MediaWrapper> getAllNetworkFav() {
List<MediaWrapper> favs = new ArrayList<MediaWrapper>();
MediaWrapper mw;
Cursor cursor = mDb.query(NETWORK_FAV_TABLE_NAME, new String[] { NETWORK_FAV_URI, NETWORK_FAV_TITLE, NETWORK_FAV_ICON_URL }, null, null, null, null, null);
if (cursor != null) {
while (cursor.moveToNext()) {
mw = new MediaWrapper(Uri.parse(cursor.getString(0)));
mw.setDisplayTitle(Uri.decode(cursor.getString(1)));
mw.setType(MediaWrapper.TYPE_DIR);
String url = cursor.getString(2);
if (!TextUtils.isEmpty(url))
mw.setArtworkURL(Uri.decode(url));
favs.add(mw);
}
cursor.close();
}
return favs;
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class MediaSortedFragment method onMediaAdded.
public void onMediaAdded(int index, Media media) {
final MediaWrapper mw = getMediaWrapper(new MediaWrapper(media));
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
addMedia(mw);
if (// we are at root level
mUri == null)
sort();
((BrowserActivityInterface) getActivity()).updateEmptyView(false);
((BrowserActivityInterface) getActivity()).showProgress(false);
}
});
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class MediaSortedFragment method getMediaWrapper.
@NonNull
private MediaWrapper getMediaWrapper(MediaWrapper media) {
MediaWrapper mw = null;
Uri uri = media.getUri();
if ((media.getType() == MediaWrapper.TYPE_AUDIO || media.getType() == MediaWrapper.TYPE_VIDEO) && "file".equals(uri.getScheme()))
mw = mMedialibrary.getMedia(uri);
if (mw == null)
return media;
return mw;
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class VideoBrowserFragment method browse.
@Override
protected void browse() {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
mVideos = VLCApplication.getMLInstance().getVideos();
mHandler.post(new Runnable() {
@Override
public void run() {
MediaWrapper media;
for (int i = 0; i < mVideos.length; ++i) {
media = mVideos[i];
Tools.setMediaDescription(media);
addMedia(media);
mMediaIndex.put(media.getLocation(), i);
}
mHandler.sendEmptyMessage(UPDATE_DISPLAY);
}
});
}
});
}
Aggregations