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;
}
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations