Search in sources :

Example 1 with MediaGroup

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

the class VideoGridFragment method onClick.

@Override
public void onClick(View v, int position, MediaLibraryItem item) {
    final MediaWrapper media = (MediaWrapper) item;
    if (mActionMode != null) {
        item.toggleStateFlag(MediaLibraryItem.FLAG_SELECTED);
        mAdapter.updateSelectionCount(item.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
        mAdapter.notifyItemChanged(position, VideoListAdapter.UPDATE_SELECTION);
        invalidateActionMode();
        return;
    }
    final Activity activity = getActivity();
    if (media instanceof MediaGroup) {
        final String title = media.getTitle().substring(media.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
        ((MainActivity) activity).showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, title);
    } else {
        media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
        final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
        if (settings.getBoolean("force_play_all", false)) {
            final List<MediaWrapper> playList = new ArrayList<>();
            MediaUtils.openList(activity, playList, mAdapter.getListWithPosition(playList, position));
        } else {
            playVideo(media, false);
        }
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaGroup(org.videolan.vlc.media.MediaGroup) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) SecondaryActivity(org.videolan.vlc.gui.SecondaryActivity) MainActivity(org.videolan.vlc.gui.MainActivity) Activity(android.app.Activity) MainActivity(org.videolan.vlc.gui.MainActivity)

Example 2 with MediaGroup

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

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)
                mService.append(((MediaGroup) media).getAll());
            else
                mService.append(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)

Example 3 with MediaGroup

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

the class VideoListAdapter method getListWithPosition.

int getListWithPosition(List<MediaWrapper> list, int position) {
    MediaWrapper mw;
    int offset = 0;
    for (int i = 0; i < getItemCount(); ++i) {
        mw = getDataset().get(i);
        if (mw instanceof MediaGroup) {
            for (MediaWrapper item : ((MediaGroup) mw).getAll()) list.add(item);
            if (i < position)
                offset += ((MediaGroup) mw).size() - 1;
        } else
            list.add(mw);
    }
    return position + offset;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaGroup(org.videolan.vlc.media.MediaGroup)

Example 4 with MediaGroup

use of org.videolan.vlc.media.MediaGroup 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)

Example 5 with MediaGroup

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

the class VideoGridFragment method onClick.

@Override
public void onClick(View v, int position, MediaLibraryItem item) {
    final MediaWrapper media = (MediaWrapper) item;
    if (mActionMode != null) {
        item.toggleStateFlag(MediaLibraryItem.FLAG_SELECTED);
        mAdapter.updateSelectionCount(item.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
        mAdapter.notifyItemChanged(position, Constants.UPDATE_SELECTION);
        invalidateActionMode();
        return;
    }
    final Activity activity = getActivity();
    if (media instanceof MediaGroup) {
        final String title = media.getTitle().substring(media.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
        ((MainActivity) activity).getNavigator().showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, title);
    } else {
        media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
        final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
        if (settings.getBoolean("force_play_all", false)) {
            final List<MediaWrapper> playList = new ArrayList<>();
            MediaUtils.openList(activity, playList, mAdapter.getListWithPosition(playList, position));
        } else {
            playVideo(media, false);
        }
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) MediaGroup(org.videolan.vlc.media.MediaGroup) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) MainActivity(org.videolan.vlc.gui.MainActivity) SecondaryActivity(org.videolan.vlc.gui.SecondaryActivity) Activity(android.app.Activity)

Aggregations

MediaGroup (org.videolan.vlc.media.MediaGroup)10 MediaWrapper (org.videolan.medialibrary.media.MediaWrapper)9 ArrayList (java.util.ArrayList)5 SharedPreferences (android.content.SharedPreferences)3 Activity (android.app.Activity)2 MenuInflater (android.view.MenuInflater)2 MainActivity (org.videolan.vlc.gui.MainActivity)2 SecondaryActivity (org.videolan.vlc.gui.SecondaryActivity)2 ContextMenuRecyclerView (org.videolan.vlc.gui.view.ContextMenuRecyclerView)2 Context (android.content.Context)1 MainThread (android.support.annotation.MainThread)1 List (java.util.List)1