use of org.videolan.libvlc.Media in project vlc-android by GeoffreyMetais.
the class MediaPlayer method setDataSource.
public void setDataSource(String path) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
mCurrentMedia = new Media(mLibVLC, path);
mMediaPlayer.setMedia(mCurrentMedia);
}
use of org.videolan.libvlc.Media in project vlc-android by GeoffreyMetais.
the class MediaPlayer method setDataSource.
// FIXME, this is INCORRECT, @headers are ignored
public void setDataSource(Context context, Uri uri, Map<String, String> headers) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
mCurrentMedia = new Media(mLibVLC, uri);
mMediaPlayer.setMedia(mCurrentMedia);
}
use of org.videolan.libvlc.Media in project vlc-android by GeoffreyMetais.
the class MediaBrowser method browse.
/**
* Browse to the specified local path starting with '/'.
*
* @param path
* @param flags see {@link MediaBrowser.Flag}
*/
@MainThread
public void browse(String path, int flags) {
final Media media = new Media(mLibVlc, path);
browse(media, flags);
media.release();
}
use of org.videolan.libvlc.Media in project vlc-android by GeoffreyMetais.
the class MediaBrowser method getMediaAt.
/**
* Get a media at a specified index. Should be released with {@link #release()}.
*/
@MainThread
public Media getMediaAt(int index) {
if (index < 0 || index >= getMediaCount())
throw new IndexOutOfBoundsException();
final Media media = mBrowserMediaList != null ? mBrowserMediaList.getMediaAt(index) : mDiscovererMediaArray.get(index);
media.retain();
return media;
}
use of org.videolan.libvlc.Media 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;
}
}
Aggregations