Search in sources :

Example 91 with MediaWrapper

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

the class ExtensionBrowser method handleContextItemSelected.

protected boolean handleContextItemSelected(MenuItem item, final int position) {
    switch(item.getItemId()) {
        case R.id.extension_item_view_play_all:
            List<VLCExtensionItem> items = mAdapter.getAll();
            List<MediaWrapper> medias = new ArrayList<>(items.size());
            for (VLCExtensionItem vlcItem : items) {
                medias.add(Utils.mediawrapperFromExtension(vlcItem));
            }
            MediaUtils.openList(getActivity(), medias, position);
            return true;
        case R.id.extension_item_view_append:
            MediaUtils.appendMedia(getActivity(), Utils.mediawrapperFromExtension(mAdapter.getItem(position)));
            return true;
        case R.id.extension_item_view_play_audio:
            MediaWrapper mw = Utils.mediawrapperFromExtension(mAdapter.getItem(position));
            mw.addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
            MediaUtils.openMedia(getActivity(), mw);
            return true;
        case R.id.extension_item_download:
        // TODO
        default:
            return false;
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ArrayList(java.util.ArrayList) VLCExtensionItem(org.videolan.vlc.extensions.api.VLCExtensionItem)

Example 92 with MediaWrapper

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

the class FilePickerFragment method browseUp.

public void browseUp() {
    if (mRoot)
        getActivity().finish();
    else if (TextUtils.equals(Strings.removeFileProtocole(mMrl), AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)) {
        mMrl = null;
        mRoot = true;
        mAdapter.clear();
        browseRoot();
    } else if (mMrl != null) {
        MediaWrapper mw = new MediaWrapper(Uri.parse(FileUtils.getParent(mMrl)));
        browse(mw, 0, false);
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 93 with MediaWrapper

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

the class NetworkBrowserFragment method handleContextItemSelected.

protected boolean handleContextItemSelected(MenuItem item, final int position) {
    int id = item.getItemId();
    if (!(mAdapter.getItem(position) instanceof MediaWrapper))
        return false;
    final MediaWrapper mw = (MediaWrapper) mAdapter.getItem(position);
    switch(id) {
        case R.id.network_add_favorite:
            MediaDatabase.getInstance().addNetworkFavItem(mw.getUri(), mw.getTitle(), mw.getArtworkURL());
            if (isRootDirectory())
                updateFavorites();
            return true;
        case R.id.network_remove_favorite:
            MediaDatabase.getInstance().deleteNetworkFav(mw.getUri());
            if (isRootDirectory())
                updateFavorites();
            return true;
        case R.id.network_edit_favorite:
            showAddServerDialog(mw);
            return true;
    }
    return super.handleContextItemSelected(item, position);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 94 with MediaWrapper

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

the class StorageBrowserFragment method onClick.

@Override
public void onClick(View v, int position, MediaLibraryItem item) {
    MediaWrapper mw = new MediaWrapper(((Storage) item).getUri());
    mw.setType(MediaWrapper.TYPE_DIR);
    browse(mw, position, ((BrowserItemBinding) DataBindingUtil.findBinding(v)).browserCheckbox.getState() == ThreeStatesCheckbox.STATE_CHECKED);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 95 with MediaWrapper

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

the class AsyncImageLoader method loadPicture.

@BindingAdapter({ "media" })
public static void loadPicture(View v, MediaLibraryItem item) {
    if (item == null || TextUtils.isEmpty(item.getArtworkMrl()) || item.getItemType() == MediaLibraryItem.TYPE_GENRE || item.getItemType() == MediaLibraryItem.TYPE_PLAYLIST)
        return;
    final boolean isMedia = item.getItemType() == MediaLibraryItem.TYPE_MEDIA;
    final boolean isGroup = isMedia && ((MediaWrapper) item).getType() == MediaWrapper.TYPE_GROUP;
    final String cacheKey = isGroup ? "group:" + item.getTitle() : item.getArtworkMrl();
    final Bitmap bitmap = sBitmapCache.getBitmapFromMemCache(cacheKey);
    if (bitmap != null) {
        updateTargetImage(bitmap, v, DataBindingUtil.findBinding(v));
        return;
    }
    if (isMedia && !isGroup && item.getId() == 0L) {
        MediaWrapper mw = (MediaWrapper) item;
        final int type = mw.getType();
        final boolean isMediaFile = type == MediaWrapper.TYPE_AUDIO || type == MediaWrapper.TYPE_VIDEO;
        final Uri uri = mw.getUri();
        if (!isMediaFile && !(type == MediaWrapper.TYPE_DIR && "upnp".equals(uri.getScheme())))
            return;
        if (isMediaFile && "file".equals(uri.getScheme())) {
            mw = sMedialibrary.getMedia(uri);
            if (mw != null)
                item = mw;
        }
    }
    loadImage(MLItemCoverFetcher.obtain().init(v, item), v);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Bitmap(android.graphics.Bitmap) Uri(android.net.Uri) BindingAdapter(android.databinding.BindingAdapter)

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