Search in sources :

Example 66 with MediaWrapper

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

the class VideoGridFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    mDividerItemDecoration = new DividerItemDecoration(requireActivity(), DividerItemDecoration.VERTICAL);
    if (mAdapter.isListMode())
        mGridView.addItemDecoration(mDividerItemDecoration);
    mGridView.setAdapter(mAdapter);
    mProvider.getDataset().observe(this, new Observer<List<MediaWrapper>>() {

        @Override
        public void onChanged(@Nullable List<MediaWrapper> mediaWrappers) {
            if (mediaWrappers != null)
                mAdapter.update(mediaWrappers);
        }
    });
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) ArrayList(java.util.ArrayList) List(java.util.List) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration)

Example 67 with MediaWrapper

use of org.videolan.medialibrary.media.MediaWrapper 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)

Example 68 with MediaWrapper

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

the class VideoGridFragment method onActionItemClicked.

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    final List<MediaWrapper> list = mAdapter.getSelection();
    if (!list.isEmpty()) {
        switch(item.getItemId()) {
            case R.id.action_video_play:
                MediaUtils.openList(getActivity(), list, 0);
                break;
            case R.id.action_video_append:
                MediaUtils.appendMedia(getActivity(), list);
                break;
            case R.id.action_video_info:
                showInfoDialog(list.get(0));
                break;
            // break;
            case R.id.action_video_download_subtitles:
                MediaUtils.getSubs(getActivity(), list);
                break;
            case R.id.action_video_play_audio:
                for (MediaWrapper media : list) media.addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
                MediaUtils.openList(getActivity(), list, 0);
                break;
            default:
                stopActionMode();
                return false;
        }
    }
    stopActionMode();
    return true;
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

Example 69 with MediaWrapper

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

the class VideoPlayerActivity method onMediaPlayerEvent.

@Override
public void onMediaPlayerEvent(MediaPlayer.Event event) {
    switch(event.type) {
        case MediaPlayer.Event.Opening:
            mHasSubItems = false;
            break;
        case MediaPlayer.Event.Playing:
            onPlaying();
            break;
        case MediaPlayer.Event.Paused:
            updateOverlayPausePlay();
            break;
        case MediaPlayer.Event.Stopped:
            exitOK();
            break;
        case MediaPlayer.Event.EndReached:
            /* Don't end the activity if the media has subitems since the next child will be
                 * loaded by the PlaybackService */
            if (!mHasSubItems)
                endReached();
            break;
        case MediaPlayer.Event.EncounteredError:
            encounteredError();
            break;
        case MediaPlayer.Event.TimeChanged:
            mProgress.set((int) event.getTimeChanged());
            break;
        case MediaPlayer.Event.LengthChanged:
            mMediaLength.set(event.getLengthChanged());
            break;
        case MediaPlayer.Event.Vout:
            updateNavStatus();
            if (mMenuIdx == -1)
                handleVout(event.getVoutCount());
            break;
        case MediaPlayer.Event.ESAdded:
            if (mMenuIdx == -1) {
                MediaWrapper media = mMedialibrary.findMedia(mService.getCurrentMediaWrapper());
                if (media == null)
                    return;
                if (event.getEsChangedType() == Media.Track.Type.Audio) {
                    setESTrackLists();
                    int audioTrack = (int) media.getMetaLong(MediaWrapper.META_AUDIOTRACK);
                    if (audioTrack != 0 || mCurrentAudioTrack != -2)
                        mService.setAudioTrack(media.getId() == 0L ? mCurrentAudioTrack : audioTrack);
                } else if (event.getEsChangedType() == Media.Track.Type.Text) {
                    setESTrackLists();
                    int spuTrack = (int) media.getMetaLong(MediaWrapper.META_SUBTITLE_TRACK);
                    if (spuTrack != 0 || mCurrentSpuTrack != -2)
                        mService.setSpuTrack(media.getId() == 0L ? mCurrentAudioTrack : spuTrack);
                }
            }
        case MediaPlayer.Event.ESDeleted:
            if (mMenuIdx == -1 && event.getEsChangedType() == Media.Track.Type.Video) {
                mHandler.removeMessages(CHECK_VIDEO_TRACKS);
                mHandler.sendEmptyMessageDelayed(CHECK_VIDEO_TRACKS, 1000);
            }
            invalidateESTracks(event.getEsChangedType());
            break;
        case MediaPlayer.Event.ESSelected:
            if (event.getEsChangedType() == Media.VideoTrack.Type.Video) {
                Media.VideoTrack vt = mService.getCurrentVideoTrack();
                changeSurfaceLayout();
                if (vt != null)
                    mFov = vt.projection == Media.VideoTrack.Projection.Rectangular ? 0f : DEFAULT_FOV;
            }
            break;
        case MediaPlayer.Event.SeekableChanged:
            updateSeekable(event.getSeekable());
            break;
        case MediaPlayer.Event.PausableChanged:
            updatePausable(event.getPausable());
            break;
        case MediaPlayer.Event.Buffering:
            if (!mIsPlaying)
                break;
            if (event.getBuffering() == 100f)
                stopLoading();
            else if (!mHandler.hasMessages(LOADING_ANIMATION) && !mIsLoading && mTouchAction != TOUCH_SEEK && !mDragging)
                mHandler.sendEmptyMessageDelayed(LOADING_ANIMATION, LOADING_ANIMATION_DELAY);
            break;
    }
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper) Media(org.videolan.libvlc.Media) SuppressLint(android.annotation.SuppressLint)

Example 70 with MediaWrapper

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

the class VideoPlayerActivity method onPlaying.

private void onPlaying() {
    mIsPlaying = true;
    setPlaybackParameters();
    stopLoading();
    updateOverlayPausePlay();
    updateNavStatus();
    final MediaWrapper mw = mService.getCurrentMediaWrapper();
    mMediaLength.set(mService.getLength());
    if (!mw.hasFlag(MediaWrapper.MEDIA_PAUSED))
        mHandler.sendEmptyMessageDelayed(FADE_OUT, OVERLAY_TIMEOUT);
    else {
        mw.removeFlags(MediaWrapper.MEDIA_PAUSED);
        mWasPaused = false;
    }
    setESTracks();
    if (mTitle != null && mTitle.length() == 0)
        mTitle.setText(mw.getTitle());
}
Also used : MediaWrapper(org.videolan.medialibrary.media.MediaWrapper)

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