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