use of org.videolan.libvlc.Media in project vlc-android by videolan.
the class VLCUtil method getThumbnail.
/**
* Get a media thumbnail.
* @return a bytearray with the RGBA thumbnail data inside.
*/
public static byte[] getThumbnail(LibVLC libVLC, Uri uri, int i_width, int i_height) {
/* dvd thumbnails can work only with dvdsimple demux */
if (uri.getLastPathSegment().endsWith(".iso"))
uri = Uri.parse("dvdsimple://" + uri.getEncodedPath());
final Media media = new Media(libVLC, uri);
byte[] bytes = getThumbnail(media, i_width, i_height);
media.release();
return bytes;
}
use of org.videolan.libvlc.Media 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.libvlc.Media in project butter-android by butterproject.
the class VlcPlayer method loadMedia.
public void loadMedia(Uri uri, int hardwareAcceleration) {
final Media media = VLCMediaOptions.builder(libVLC, uri).withHardwareAcceleration(hardwareAcceleration).build();
mediaPlayer.setMedia(media);
}
use of org.videolan.libvlc.Media in project vlc-android by GeoffreyMetais.
the class MediaPlayer method setDataSource.
public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException {
mCurrentMedia = new Media(mLibVLC, fd);
mMediaPlayer.setMedia(mCurrentMedia);
}
use of org.videolan.libvlc.Media in project vlc-android by GeoffreyMetais.
the class MediaBrowser method browse.
/**
* Browse to the specified uri.
*
* @param uri
* @param flags see {@link MediaBrowser.Flag}
*/
@MainThread
public void browse(Uri uri, int flags) {
final Media media = new Media(mLibVlc, uri);
browse(media, flags);
media.release();
}
Aggregations