Search in sources :

Example 61 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by GeoffreyMetais.

the class MediaDatabase method getMedia.

public synchronized MediaWrapper getMedia(Uri uri) {
    Cursor cursor;
    MediaWrapper media = null;
    try {
        cursor = mDb.query(MEDIA_TABLE_NAME, new String[] { // 0 long
        MEDIA_TIME, // 1 long
        MEDIA_LENGTH, // 2 int
        MEDIA_TYPE, // 3 string
        MEDIA_TITLE, // 4 string
        MEDIA_ARTIST, // 5 string
        MEDIA_GENRE, // 6 string
        MEDIA_ALBUM, // 7 string
        MEDIA_ALBUMARTIST, // 8 int
        MEDIA_WIDTH, // 9 int
        MEDIA_HEIGHT, // 10 string
        MEDIA_ARTWORKURL, // 11 int
        MEDIA_AUDIOTRACK, // 12 int
        MEDIA_SPUTRACK, // 13 int
        MEDIA_TRACKNUMBER, // 14 int
        MEDIA_DISCNUMBER, // 15 long
        MEDIA_LAST_MODIFIED }, MEDIA_LOCATION + "=?", new String[] { uri.toString() }, null, null, null);
    } catch (IllegalArgumentException e) {
        // java.lang.IllegalArgumentException: the bind value at index 1 is null
        return null;
    }
    if (cursor != null) {
        if (cursor.moveToFirst()) {
            media = new MediaWrapper(uri, cursor.getLong(0), cursor.getLong(1), cursor.getInt(2), // lazy loading, see getPicture()
            null, cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getInt(8), cursor.getInt(9), cursor.getString(10), cursor.getInt(11), cursor.getInt(12), cursor.getInt(13), cursor.getInt(14), cursor.getLong(15), 0L);
        }
        cursor.close();
    }
    return media;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Cursor(android.database.Cursor)

Example 62 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by GeoffreyMetais.

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 63 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by GeoffreyMetais.

the class MediaWrapperList method move.

/**
 * Move a media from one position to another
 *
 * @param startPosition start position
 * @param endPosition end position
 * @throws IndexOutOfBoundsException
 */
public synchronized void move(int startPosition, int endPosition) {
    if (!(isValid(startPosition) && endPosition >= 0 && endPosition <= mInternalList.size()))
        throw new IndexOutOfBoundsException("Indexes out of range");
    MediaWrapper toMove = mInternalList.get(startPosition);
    mInternalList.remove(startPosition);
    if (startPosition >= endPosition)
        mInternalList.add(endPosition, toMove);
    else
        mInternalList.add(endPosition - 1, toMove);
    signalEventListeners(EVENT_MOVED, startPosition, endPosition, toMove.getLocation());
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 64 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by GeoffreyMetais.

the class ThumbnailsProvider method composeImage.

/**
 * Compose 1 image from combined media thumbnails
 * @param group The MediaGroup instance
 * @return a Bitmap object
 */
private static Bitmap composeImage(MediaGroup group) {
    final Bitmap[] sourcesImages = new Bitmap[Math.min(MAX_IMAGES, group.size())];
    int count = 0, minWidth = Integer.MAX_VALUE, minHeight = Integer.MAX_VALUE;
    for (MediaWrapper media : group.getAll()) {
        final Bitmap bm = getVideoThumbnail(media);
        if (bm != null) {
            int width = bm.getWidth();
            int height = bm.getHeight();
            sourcesImages[count++] = bm;
            minWidth = Math.min(minWidth, width);
            minHeight = Math.min(minHeight, height);
            if (count == MAX_IMAGES)
                break;
        }
    }
    if (count == 0)
        return null;
    if (count == 1)
        return sourcesImages[0];
    return composeCanvas(sourcesImages, count, minWidth, minHeight);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) AudioUtil.readCoverBitmap(org.videolan.vlc.gui.helpers.AudioUtil.readCoverBitmap) Bitmap(android.graphics.Bitmap)

Example 65 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by GeoffreyMetais.

the class VideoGridFragment method handleContextItemSelected.

protected boolean handleContextItemSelected(MenuItem menu, final int position) {
    if (position >= mAdapter.getItemCount())
        return false;
    final MediaWrapper media = mAdapter.getItem(position);
    if (media == null)
        return false;
    switch(menu.getItemId()) {
        case R.id.video_list_play_from_start:
            playVideo(media, true);
            return true;
        case R.id.video_list_play_audio:
            playAudio(media);
            return true;
        case R.id.video_list_play_all:
            List<MediaWrapper> playList = new ArrayList<>();
            MediaUtils.openList(getActivity(), playList, mAdapter.getListWithPosition(playList, position));
            return true;
        case R.id.video_list_info:
            showInfoDialog(media);
            return true;
        case R.id.video_list_delete:
            removeVideo(media);
            return true;
        case R.id.video_group_play:
            MediaUtils.openList(getActivity(), ((MediaGroup) media).getAll(), 0);
            return true;
        case R.id.video_list_append:
            if (media instanceof MediaGroup)
                MediaUtils.appendMedia(getActivity(), ((MediaGroup) media).getAll());
            else
                MediaUtils.appendMedia(getActivity(), media);
            return true;
        case R.id.video_download_subtitles:
            MediaUtils.getSubs(getActivity(), media);
            return true;
    }
    return false;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaGroup(org.videolan.vlc.media.MediaGroup) ArrayList(java.util.ArrayList)

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