use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class AudioUtil method getCover.
public static Bitmap getCover(Context context, List<MediaWrapper> list, int width, boolean fromMemCache) {
Bitmap cover = null;
LinkedList<String> testedAlbums = new LinkedList<String>();
for (MediaWrapper media : list) {
/* No list cover is artist or album are null */
if (media.getAlbum() == null || media.getArtist() == null)
continue;
if (testedAlbums.contains(media.getAlbum()))
continue;
cover = fromMemCache ? AudioUtil.getCoverFromMemCache(context, media, width) : AudioUtil.getCover(context, media, width);
if (cover != null)
break;
else if (media.getAlbum() != null)
testedAlbums.add(media.getAlbum());
}
return cover;
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
the class VideoListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final MediaWrapper media = getDataset().get(position);
if (media == null)
return;
holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.CENTER_CROP);
fillView(holder, media);
holder.binding.setVariable(BR.media, media);
holder.selectView(media.hasStateFlags(MediaLibraryItem.FLAG_SELECTED));
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
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());
}
use of org.videolan.medialibrary.media.MediaWrapper in project vlc-android by videolan.
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 videolan.
the class TvUtil method playMedia.
public static void playMedia(Activity activity, MediaWrapper media) {
if (media.getType() == MediaWrapper.TYPE_AUDIO) {
ArrayList<MediaWrapper> tracks = new ArrayList<>();
tracks.add(media);
Intent intent = new Intent(activity, AudioPlayerActivity.class);
intent.putExtra(AudioPlayerActivity.MEDIA_LIST, tracks);
activity.startActivity(intent);
} else
MediaUtils.openMedia(activity, media);
}
Aggregations