use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class AudioBrowserFragment method onFabPlayClick.
@Override
public void onFabPlayClick(View view) {
final List<MediaWrapper> list = ((List<MediaWrapper>) (List<?>) mSongsAdapter.getMediaItems());
int count = list.size();
if (count > 0) {
Random rand = new Random();
int randomSong = rand.nextInt(count);
if (mService != null) {
mService.load(list, randomSong);
if (!mService.isShuffling())
mService.shuffle();
}
}
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class PlaylistAdapter method onItemDismiss.
@Override
public void onItemDismiss(final int position) {
final MediaWrapper media = getItem(position);
String message = String.format(VLCApplication.getAppResources().getString(R.string.remove_playlist_item), media.getTitle());
if (mAudioPlayer instanceof Fragment) {
View v = ((Fragment) mAudioPlayer).getView();
Runnable cancelAction = new Runnable() {
@Override
public void run() {
mService.insertItem(position, media);
}
};
UiTools.snackerWithCancel(v, message, null, cancelAction);
} else if (mAudioPlayer instanceof Context) {
Toast.makeText(VLCApplication.getAppContext(), message, Toast.LENGTH_SHORT).show();
}
remove(position);
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class CardPresenter method onBindViewHolder.
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, final Object item) {
ViewHolder holder = ((ViewHolder) viewHolder);
if (item instanceof MediaWrapper) {
final MediaWrapper mediaWrapper = (MediaWrapper) item;
holder.mCardView.setTitleText(mediaWrapper.getTitle());
holder.mCardView.setContentText(mediaWrapper.getDescription());
if (mediaWrapper.getType() == MediaWrapper.TYPE_GROUP)
holder.updateCardViewImage(ContextCompat.getDrawable(mContext, R.drawable.ic_video_collection_big));
else {
holder.updateCardViewImage(mediaWrapper);
if (mIsSeenMediaMarkerVisible && mediaWrapper.getType() == MediaWrapper.TYPE_VIDEO && mediaWrapper.getSeen() > 0L)
holder.mCardView.setBadgeImage(ContextCompat.getDrawable(mContext, R.drawable.ic_seen_tv_normal));
}
holder.view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
TvUtil.showMediaDetail(v.getContext(), mediaWrapper);
return true;
}
});
} else if (item instanceof MediaLibraryItem) {
MediaLibraryItem mediaLibraryItem = (MediaLibraryItem) item;
holder.mCardView.setTitleText(mediaLibraryItem.getTitle());
holder.mCardView.setContentText(mediaLibraryItem.getDescription());
holder.updateCardViewImage(mediaLibraryItem);
} else if (item instanceof SimpleCard) {
SimpleCard card = (SimpleCard) item;
Bitmap image = card.getImage();
holder.mCardView.setTitleText(card.getName());
holder.mCardView.setContentText(card.getDescription());
holder.updateCardViewImage(image != null ? new BitmapDrawable(mRes, image) : ContextCompat.getDrawable(mContext, card.getImageId()));
} else if (item instanceof String) {
holder.mCardView.setTitleText((String) item);
holder.mCardView.setContentText("");
holder.updateCardViewImage(sDefaultCardImage);
}
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class MainTvActivity method onKeyDown.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_BUTTON_Y) && mSelectedItem instanceof MediaWrapper) {
MediaWrapper media = (MediaWrapper) mSelectedItem;
if (media.getType() != MediaWrapper.TYPE_DIR)
return false;
final Intent intent = new Intent(this, DetailsActivity.class);
// pass the item information
intent.putExtra("media", (MediaWrapper) mSelectedItem);
intent.putExtra("item", new MediaItemDetails(media.getTitle(), media.getArtist(), media.getAlbum(), media.getLocation(), media.getArtworkURL()));
startActivity(intent);
return true;
}
return super.onKeyDown(keyCode, event);
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class MainTvActivity method updateNowPlayingCard.
public void updateNowPlayingCard() {
if (mService == null)
return;
final boolean hasmedia = mService.hasMedia();
final boolean canSwitch = mService.canSwitchToVideo();
if ((!hasmedia || canSwitch) && mNowPlayingCard != null) {
mCategoriesAdapter.removeItems(0, 1);
mNowPlayingCard = null;
} else if (hasmedia && !canSwitch) {
final MediaWrapper mw = mService.getCurrentMediaWrapper();
final String display = MediaUtils.getMediaTitle(mw) + " - " + MediaUtils.getMediaReferenceArtist(MainTvActivity.this, mw);
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final Bitmap cover = AudioUtil.readCoverBitmap(Uri.decode(mw.getArtworkMrl()), VLCApplication.getAppResources().getDimensionPixelSize(R.dimen.grid_card_thumb_width));
VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
if (mNowPlayingCard == null) {
if (cover != null)
mNowPlayingCard = new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, cover);
else
mNowPlayingCard = new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, R.drawable.ic_default_cone);
mCategoriesAdapter.add(0, mNowPlayingCard);
} else {
mNowPlayingCard.setId(MusicFragment.CATEGORY_NOW_PLAYING);
mNowPlayingCard.setName(display);
if (cover != null)
mNowPlayingCard.setImage(cover);
else
mNowPlayingCard.setImageId(R.drawable.ic_default_cone);
}
mCategoriesAdapter.notifyArrayItemRangeChanged(0, 1);
}
});
}
});
}
}
Aggregations