Search in sources :

Example 31 with MediaWrapper

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

Example 32 with MediaWrapper

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);
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Context(android.content.Context) Fragment(android.support.v4.app.Fragment) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 33 with MediaWrapper

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);
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Bitmap(android.graphics.Bitmap) MediaLibraryItem(org.videolan.medialibrary.media.MediaLibraryItem) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageCardView(android.support.v17.leanback.widget.ImageCardView) ImageView(android.widget.ImageView) View(android.view.View)

Example 34 with MediaWrapper

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

Example 35 with MediaWrapper

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

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