Search in sources :

Example 11 with MediaWrapper

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;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ArrayMap(android.support.v4.util.ArrayMap) Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 12 with MediaWrapper

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;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 13 with MediaWrapper

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);
        }
    });
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 14 with MediaWrapper

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;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Uri(android.net.Uri) NonNull(android.support.annotation.NonNull)

Example 15 with MediaWrapper

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);
                }
            });
        }
    });
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Aggregations

MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)157 ArrayList (java.util.ArrayList)36 MediaLibraryItem (org.videolan.medialibrary.media.MediaLibraryItem)23 Bitmap (android.graphics.Bitmap)18 Intent (android.content.Intent)16 Uri (android.net.Uri)15 List (java.util.List)11 Bundle (android.os.Bundle)10 Context (android.content.Context)9 MediaGroup (org.videolan.vlc.media.MediaGroup)9 PendingIntent (android.app.PendingIntent)8 View (android.view.View)8 TargetApi (android.annotation.TargetApi)6 Cursor (android.database.Cursor)6 FragmentManager (android.support.v4.app.FragmentManager)6 File (java.io.File)6 LinkedList (java.util.LinkedList)6 Medialibrary (org.videolan.medialibrary.Medialibrary)6 SavePlaylistDialog (org.videolan.vlc.gui.dialogs.SavePlaylistDialog)6 SharedPreferences (android.content.SharedPreferences)5