org.videolan.libvlc.LibVLC Java Examples

The following examples show how to use org.videolan.libvlc.LibVLC. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VLCSampleExtractor.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
public VLCSampleExtractor(LibVLC vlc, String uri) throws ExoPlaybackException {
	if (vlc == null || uri == null)
		throw new ExoPlaybackException("null parms!");
	this.uri = uri;
	this.lib = vlc;
	this.media = ExoVlcUtil.getMedia(vlc, uri);
	this.vlctracks = ExoVlcUtil.getAvailableTracks(media);
	if (this.vlctracks.length > 0)
		this.trackInfos = ExoVlcUtil.vlc2exoTracks(media.getDuration(), vlctracks, lib);
	else
		try {
			if ((hasVdo = vlc.hasVideoTrack(uri)))
				this.trackInfos = ExoVlcUtil.getDummyVdoTrack(media,
						com.exovlc.ExoVlcUtil.DUMM_VDO_MIME);
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	ExoVlcUtil.log(this, "get vlc tracks for uri = " + uri);

}
 
Example #2
Source File: VLCVideoSurfaceHandler.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
public VLCVideoSurfaceHandler( LibVLC libvlc, Handler eventHandler,
		MediaCodecVideoTrackRenderer.EventListener eventListener, SurfaceLayoutHandler layoutHandler) throws ExoPlaybackException {
	super();
	this.libvlc = libvlc;
	this.eventHandler = eventHandler;
	this.eventListener = eventListener;

	
	if (layoutHandler != null) {
		this.layoutHandler = layoutHandler;
			SurfaceHolder surfaceHolder = layoutHandler.getHolder();
		ExoVlcUtil.log(this, "VLCIVideoSurfaceHandler.VLCIVideoSurfaceHandler()");
		ExoVlcUtil.log(this, "## ====> rect= " + surfaceHolder.getSurfaceFrame());
		if (com.exovlc.ExoVlcUtil.validSurface(surfaceHolder))
			setVlcSurface(surfaceHolder.getSurface(), false);

	} else
		throw new ExoPlaybackException("layout handler null.");

}
 
Example #3
Source File: VLCSampleExtractor.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
public VLCSampleExtractor(LibVLC vlc, String uri) throws ExoPlaybackException {
	if (vlc == null || uri == null)
		throw new ExoPlaybackException("null parms!");
	this.uri = uri;
	this.lib = vlc;
	this.media = ExoVlcUtil.getMedia(vlc, uri);
	this.vlctracks = ExoVlcUtil.getAvailableTracks(media);
	if (this.vlctracks.length > 0)
		this.trackInfos = ExoVlcUtil.vlc2exoTracks(media.getDuration(), vlctracks, lib);
	else
		try {
			if ((hasVdo = vlc.hasVideoTrack(uri)))
				this.trackInfos = ExoVlcUtil.getDummyVdoTrack(media,
						com.exovlc.ExoVlcUtil.DUMM_VDO_MIME);
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	ExoVlcUtil.log(this, "get vlc tracks for uri = " + uri);

}
 
Example #4
Source File: ExoVlcUtil.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param media
 * @param vlcTracks
 * @param lib
 * @return
 */
static com.google.android.exoplayer.TrackInfo[] vlc2exoTracks(long duration,
		org.videolan.libvlc.Media.Track[] vlcTracks, LibVLC lib) {
	com.google.android.exoplayer.TrackInfo[] res = new com.google.android.exoplayer.TrackInfo[vlcTracks.length];
	System.out.println("ExoVlcUtil.vlc2exoTracks() vlcTracks = " + vlcTracks.length);
	// Media.Track
	for (int i = 0; i < res.length; i++) {
		MediaFormat mf = track2mediaFormat(vlcTracks[i]);

		res[i] = new TrackInfo(mf.getString(MediaFormat.KEY_MIME), duration);
		System.out.println("\t track " + i + " mime type =" + mf.getString(MediaFormat.KEY_MIME) + " duration ="
				+ duration);
	}
	/*
	 * System.out.println(">>>> ExoVlcUtil.vlc2exoTracks() vlcTracks.length = "
	 * +vlcTracks.length); long l; for (int i = 0; i < vlcTracks.length;
	 * i++) { org.videolan.libvlc.TrackInfo vt = vlcTracks[i];
	 * System.out.println("\t\t >>>>>Codec("+i+") "+vlcTracks[i].Codec);
	 * res[i] = new TrackInfo( vt.Codec, (l=lib.getLength()) == -1 ?
	 * com.google.android.exoplayer.C.UNKNOWN_TIME_US : l * MS_2_MICRO); }
	 */
	return res;
}
 
Example #5
Source File: ExoVlcUtil.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param media
 * @param vlcTracks
 * @param lib
 * @return
 */
static com.google.android.exoplayer.TrackInfo[] vlc2exoTracks(long duration,
		org.videolan.libvlc.Media.Track[] vlcTracks, LibVLC lib) {
	com.google.android.exoplayer.TrackInfo[] res = new com.google.android.exoplayer.TrackInfo[vlcTracks.length];
	System.out.println("ExoVlcUtil.vlc2exoTracks() vlcTracks = " + vlcTracks.length);
	// Media.Track
	for (int i = 0; i < res.length; i++) {
		MediaFormat mf = track2mediaFormat(vlcTracks[i]);

		res[i] = new TrackInfo(mf.getString(MediaFormat.KEY_MIME), duration);
		System.out.println("\t track " + i + " mime type =" + mf.getString(MediaFormat.KEY_MIME) + " duration ="
				+ duration);
	}
	/*
	 * System.out.println(">>>> ExoVlcUtil.vlc2exoTracks() vlcTracks.length = "
	 * +vlcTracks.length); long l; for (int i = 0; i < vlcTracks.length;
	 * i++) { org.videolan.libvlc.TrackInfo vt = vlcTracks[i];
	 * System.out.println("\t\t >>>>>Codec("+i+") "+vlcTracks[i].Codec);
	 * res[i] = new TrackInfo( vt.Codec, (l=lib.getLength()) == -1 ?
	 * com.google.android.exoplayer.C.UNKNOWN_TIME_US : l * MS_2_MICRO); }
	 */
	return res;
}
 
Example #6
Source File: VLCVideoSurfaceHandler.java    From Exoplayer_VLC with Apache License 2.0 6 votes vote down vote up
public VLCVideoSurfaceHandler( LibVLC libvlc, Handler eventHandler,
		MediaCodecVideoTrackRenderer.EventListener eventListener, SurfaceLayoutHandler layoutHandler) throws ExoPlaybackException {
	super();
	this.libvlc = libvlc;
	this.eventHandler = eventHandler;
	this.eventListener = eventListener;

	
	if (layoutHandler != null) {
		this.layoutHandler = layoutHandler;
			SurfaceHolder surfaceHolder = layoutHandler.getHolder();
		ExoVlcUtil.log(this, "VLCIVideoSurfaceHandler.VLCIVideoSurfaceHandler()");
		ExoVlcUtil.log(this, "## ====> rect= " + surfaceHolder.getSurfaceFrame());
		if (com.exovlc.ExoVlcUtil.validSurface(surfaceHolder))
			setVlcSurface(surfaceHolder.getSurface(), false);

	} else
		throw new ExoPlaybackException("layout handler null.");

}
 
Example #7
Source File: VlcVideoLibrary.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface, int width,
    int height) {
  this.vlcListener = vlcListener;
  this.surface = surface;
  this.width = width;
  this.height = height;
  surfaceHolder = null;
  vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
  options.add(":fullscreen");
}
 
Example #8
Source File: VLCUtil.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: VlcVideoLibrary.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface,
    SurfaceHolder surfaceHolder) {
  this.vlcListener = vlcListener;
  this.surface = surface;
  this.surfaceHolder = surfaceHolder;
  vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
  options.add(":fullscreen");
}
 
Example #10
Source File: VlcVideoLibrary.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface) {
  this.vlcListener = vlcListener;
  this.surface = surface;
  surfaceHolder = null;
  vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
  options.add(":fullscreen");
}
 
Example #11
Source File: FullscreenVlcPlayer.java    From VLC-Simple-Player-Android with MIT License 5 votes vote down vote up
/**
 * **********
 * Player
 * ***********
 */

private void createPlayer(String media) {
    releasePlayer();
    setupControls();
    try {
        if (media.length() > 0) {
            Toast toast = Toast.makeText(this, media, Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                    0);
            toast.show();
        }

        // Create a new media player
        libvlc = LibVLC.getInstance();
        libvlc.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL);
        libvlc.eventVideoPlayerActivityCreated(true);
        libvlc.setSubtitlesEncoding("");
        libvlc.setAout(LibVLC.AOUT_OPENSLES);
        libvlc.setTimeStretching(true);
        libvlc.setChroma("RV32");
        libvlc.setVerboseMode(true);
        LibVLC.restart(this);
        EventHandler.getInstance().addHandler(mHandler);
        holder.setFormat(PixelFormat.RGBX_8888);
        holder.setKeepScreenOn(true);
        MediaList list = libvlc.getMediaList();
        list.clear();
        list.add(new Media(libvlc, LibVLC.PathToURI(media)), false);
        libvlc.playIndex(0);
    } catch (Exception e) {
        Toast.makeText(this, "Could not create Vlc Player", Toast.LENGTH_LONG).show();
    }
}
 
Example #12
Source File: ExoVlcUtil.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
static void releaseVLC(LibVLC lib) {
	synchronized (ExoVlcUtil.class) {
		if (lib != null) {
			lib.destroy();
			lib = null;
		}
		libCtx = null;
	}
}
 
Example #13
Source File: ExoVlcUtil.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
public static org.videolan.libvlc.Media getMedia(LibVLC vlc, String uri) throws ExoPlaybackException {
	System.out.println(">> ExoVlcUtil.getMedia() uri = " + uri);

	org.videolan.libvlc.Media media = new org.videolan.libvlc.Media(vlc, uri);

	boolean parsed = media.parse(org.videolan.libvlc.Media.Parse.FetchNetwork);
	media.release();
	System.out.println("ExoVlcUtil.getMedia() is parsed media=" + media.isParsed());
	System.out.println("ExoVlcUtil.getMedia() media duration =");

	MediaList mlist = media.subItems();
	System.out.println("ExoVlcUtil.getMedia() sub item =" + mlist);
	if (mlist != null) {
		System.out.println(">>> ExoVlcUtil.getMedia() parsed media subItems count : " + mlist.getCount());
		for (int i = 0; i < mlist.getCount(); i++) {
			System.out.println(">>> ExoVlcUtil.getMedia() parsed media subItems item (" + i + ") : "
					+ mlist.getMediaAt(i).getType() + " track count " + mlist.getMediaAt(i).getTrackCount());

		}
	}
	System.out.println(">>> ExoVlcUtil.getMedia() parsed media  dump tracks : " + media.getTrackCount());
	for (int i = 0; i < media.getTrackCount(); i++) {
		System.out.println(">>> ExoVlcUtil.getMedia() parsed media  track[" + i + "]:" + media.getTrack(i).type);

	}

	// try {
	// boolean hv =vlc.hasVideoTrack(uri);
	// System.out.println(">>> ExoVlcUtil.getMedia() HAS VDO="+hv);
	// } catch (IOException e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// }
	//
	if (!parsed)
		throw new ExoPlaybackException("Unable to parse media " + uri);
	return media;
}
 
Example #14
Source File: ExoVlcUtil.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
static void releaseVLC(LibVLC lib) {
	synchronized (ExoVlcUtil.class) {
		if (lib != null) {
			lib.destroy();
			lib = null;
		}
		libCtx = null;
	}
}
 
Example #15
Source File: ExoVlcUtil.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
public static org.videolan.libvlc.Media getMedia(LibVLC vlc, String uri) throws ExoPlaybackException {
	System.out.println(">> ExoVlcUtil.getMedia() uri = " + uri);

	org.videolan.libvlc.Media media = new org.videolan.libvlc.Media(vlc, uri);

	boolean parsed = media.parse(org.videolan.libvlc.Media.Parse.FetchNetwork);
	media.release();
	System.out.println("ExoVlcUtil.getMedia() is parsed media=" + media.isParsed());
	System.out.println("ExoVlcUtil.getMedia() media duration =");

	MediaList mlist = media.subItems();
	System.out.println("ExoVlcUtil.getMedia() sub item =" + mlist);
	if (mlist != null) {
		System.out.println(">>> ExoVlcUtil.getMedia() parsed media subItems count : " + mlist.getCount());
		for (int i = 0; i < mlist.getCount(); i++) {
			System.out.println(">>> ExoVlcUtil.getMedia() parsed media subItems item (" + i + ") : "
					+ mlist.getMediaAt(i).getType() + " track count " + mlist.getMediaAt(i).getTrackCount());

		}
	}
	System.out.println(">>> ExoVlcUtil.getMedia() parsed media  dump tracks : " + media.getTrackCount());
	for (int i = 0; i < media.getTrackCount(); i++) {
		System.out.println(">>> ExoVlcUtil.getMedia() parsed media  track[" + i + "]:" + media.getTrack(i).type);

	}

	// try {
	// boolean hv =vlc.hasVideoTrack(uri);
	// System.out.println(">>> ExoVlcUtil.getMedia() HAS VDO="+hv);
	// } catch (IOException e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// }
	//
	if (!parsed)
		throw new ExoPlaybackException("Unable to parse media " + uri);
	return media;
}
 
Example #16
Source File: Dumper.java    From libvlc-android-sdk with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example #17
Source File: VLCUtil.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: VlcVideoLibrary.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface,
    SurfaceHolder surfaceHolder, int width, int height) {
  this.vlcListener = vlcListener;
  this.surface = surface;
  this.surfaceHolder = surfaceHolder;
  this.width = width;
  this.height = height;
  vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
  options.add(":fullscreen");
}
 
Example #19
Source File: FragmentVideoPlayer.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
private void createPlayer() {
    releasePlayer();
    String videoLink = UniversalPlayer.getInstance().getPlayingMediaItem().getAudeoLink();
    try {
        Logger.printInfo(TAG, "Trying to play video: " + videoLink);

        ArrayList<String> options = new ArrayList<String>();
        options.add("--aout=opensles");
        options.add("--audio-time-stretch"); // time stretching
        options.add("-vvv"); // verbosity
        libvlc = new LibVLC(options);
        shVideoHolder.setKeepScreenOn(true);

        // Create media player
        mMediaPlayer = new MediaPlayer(libvlc);
        mMediaPlayer.setEventListener(this);

        // Set up video output
        final IVLCVout vout = mMediaPlayer.getVLCVout();
        vout.setVideoView(sfVideo);
        vout.addCallback(this);
        vout.attachViews();

        Media m = URLUtil.isValidUrl(videoLink) ? new Media(libvlc, Uri.parse(videoLink)) : new Media(libvlc, videoLink);
        mMediaPlayer.setMedia(m);
        mMediaPlayer.play();
    } catch (Exception e) {
        Logger.printInfo(TAG, "Error creating video player: ");
        e.printStackTrace();
        if (onPlayingFailedCallback != null) {
            onPlayingFailedCallback.operationFinished();
        }
    }
}
 
Example #20
Source File: VLCRendererBuilder.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
public VLCRendererBuilder(Context context, Uri uri, Properties props) throws ExoPlaybackException {
    this.context = context;
    this.uri = LibVLC.PathToURI(uri.toString());
    this.vlc = ExoVlcUtil.getVLC(context);
    this.props = props;

}
 
Example #21
Source File: MediaBrowser.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param libvlc   The LibVLC instance to use
 * @param listener The Listener which will receive callbacks
 *                 <p>
 *                 With this constructor, callbacks will be executed in the main thread
 */
public MediaBrowser(LibVLC libvlc, EventListener listener) {
    mLibVlc = libvlc;
    mLibVlc.retain();
    mEventListener = listener;
    mAlive = true;
}
 
Example #22
Source File: VideoActivity.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
private synchronized void createPlayer(String media  ) {
    releasePlayer();
 //   mSurfaceView.setKeepScreenOn(true);
    LibVLC libvlc = getLibVLC(); 
	 System.out.println("## Attache vlc lib to surface rec = "+mSurfaceHolder.getSurfaceFrame());
	 
    // libvlc.attachSurface(mSurfaceHolder.getSurface(), this);
    
    try {
        if (media.length() > 0) {
            Toast toast = Toast.makeText(this, media, Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,     0);
            toast.show();
        }
 
        String[] options = libvlc.getMediaOptions(!true, !libvlc.hasVideoTrack(media));
        System.out.println(">>VideoActivity.createPlayer() OPTIONS:");
        for (int i = 0; i < options.length; i++) 
System.out.println(" o-"+i+":"+options[i]);
			
        libvlc.playMRL(media,options);
        System.out.println(" CREATED OPTION WITH : noHardwareAcceleration = !true  & noVideo ="+ ! libvlc.hasVideoTrack(media));
        System.out.println(">>>>>>>VideoActivity.createPlayer() AUDIOS = "+libvlc.getAudioTracksCount()+ "\n\tAudio track ="+libvlc.getAudioTrack()+ "\n\t VIDEOS = "+ libvlc.getVideoTracksCount() +
        		"\n\t AUDIO DESCs = " + libvlc. getAudioTrackDescription()+"\n\t HAS VIDEO  DESCs = " + libvlc.hasVideoTrack(media)
        		+"\n\t HAS HardwareAcceleration = " + libvlc.getHardwareAcceleration());
        
    } catch (Exception e) {
    	e.printStackTrace();
        Toast.makeText(this, "Error creating player!", Toast.LENGTH_LONG).show();
    }
}
 
Example #23
Source File: VLCUtil.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #24
Source File: Dumper.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 *
 * @param uri      the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example #25
Source File: VideoActivity.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/*************
  * Player
  *************/
 LibVLC getLibVLC(){
 	if(true)
try {
	return com.exovlc.ExoVlcUtil.getVLC(this);
} catch (ExoPlaybackException e1) {
	// TODO Auto-generated catch block
	e1.printStackTrace();
	finish();
}
throw new IllegalStateException();
 }
 
Example #26
Source File: VideoActivity.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
/*************
   * Activity
   *************/

  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.player_activity);
      // Receive path to play from intent
      Intent intent = getIntent();
      if(intent==null|| intent.getExtras()==null || (mFilePath = intent.getExtras().getString(LOCATION))!=null)
       mFilePath =LibVLC.PathToURI("/data/local/tmp/air_stunt_1.mp4");
       System.out.println("###########################################################");
       System.out.println("###########################################################");
       System.out.println("###########################################################");
       System.out.println("###########################################################");
       System.out.println("###########################################################");
       System.out.println(">>>> VideoActivity.onCreate() File PATH = "+mFilePath);
       System.out.println("###########################################################");
       System.out.println("###########################################################");
       System.out.println("###########################################################");
       System.out.println("###########################################################");
       
       
      //   mFilePath = LibVLC.PathToURI("/data/local/tmp/air_stunt_1.mp4");// intent.getExtras().getString(LOCATION);
      //  mFilePath = LibVLC.PathToURI("/data/local/tmp/5.0_de.ac3");
       
       
      Log.d(TAG, "Playing back " + mFilePath);
      mSurfaceView = (SurfaceView) findViewById(R.id.surface_view);
      mSurfaceHolder = mSurfaceView.getHolder();
setVlcSurface(mSurfaceHolder);

     
  }
 
Example #27
Source File: VLCRendererBuilder.java    From Exoplayer_VLC with Apache License 2.0 5 votes vote down vote up
public VLCRendererBuilder(Context context, Uri uri, Properties props) throws ExoPlaybackException {
    this.context = context;
    this.uri = LibVLC.PathToURI(uri.toString());
    this.vlc = ExoVlcUtil.getVLC(context);
    this.props = props;

}
 
Example #28
Source File: VLCUtil.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #29
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
private MediaPlayer newMediaPlayer() {
    final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    final MediaPlayer mp = new MediaPlayer(LibVLC());
    final String aout = VLCOptions.getAout(pref);
    if (mp.setAudioOutput(aout) && aout.equals("android_audiotrack")) {
        mIsAudioTrack = true;
        if (mHasHdmiAudio)
            mp.setAudioOutputDevice("hdmi");
    } else
        mIsAudioTrack = false;
    mp.getVLCVout().addCallback(this);

    return mp;
}
 
Example #30
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void createPresentation() {
    if (mMediaRouter == null || mEnableCloneMode)
        return;

    // Get the current route and its presentation display.
    MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(
        MediaRouter.ROUTE_TYPE_LIVE_VIDEO);

    Display presentationDisplay = route != null ? route.getPresentationDisplay() : null;

    if (presentationDisplay != null) {
        // Show a new presentation if possible.
        Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        mPresentation = new SecondaryDisplay(this, LibVLC(), presentationDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);
        try {
            mPresentation.show();
            mPresentationDisplayId = presentationDisplay.getDisplayId();
        } catch (WindowManager.InvalidDisplayException ex) {
            Log.w(TAG, "Couldn't show presentation!  Display was removed in "
                    + "the meantime.", ex);
            mPresentation = null;
        }
    } else
        Log.i(TAG, "No secondary display detected");
}