Skip to content

Commit

Permalink
add options to player
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Mar 19, 2018
1 parent 6031709 commit 4efa0ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# vlc-example-streamplayer

[![Release](https://jitpack.io/v/pedroSG94/vlc-example-streamplayer.svg)](https://jitpack.io/#pedroSG94/vlc-example-streamplayer)

Example code how to play a stream with VLC.

Use this endpoint for test:
Expand Down
19 changes: 18 additions & 1 deletion pedrovlc/src/main/java/com/pedro/vlc/VlcVideoLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
import java.util.ArrayList;
import org.videolan.libvlc.IVLCVout;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
Expand All @@ -28,30 +29,35 @@ public class VlcVideoLibrary implements MediaPlayer.EventListener {
private SurfaceTexture surfaceTexture;
private Surface surface;
private SurfaceHolder surfaceHolder;
private ArrayList<String> options = new ArrayList<>();

public VlcVideoLibrary(Context context, VlcListener vlcListener, SurfaceView surfaceView) {
this.vlcListener = vlcListener;
this.surfaceView = surfaceView;
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
options.add(":fullscreen");
}

public VlcVideoLibrary(Context context, VlcListener vlcListener, TextureView textureView) {
this.vlcListener = vlcListener;
this.textureView = textureView;
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
options.add(":fullscreen");
}

public VlcVideoLibrary(Context context, VlcListener vlcListener, SurfaceTexture surfaceTexture) {
this.vlcListener = vlcListener;
this.surfaceTexture = surfaceTexture;
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
options.add(":fullscreen");
}

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");
}

public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface,
Expand All @@ -60,6 +66,7 @@ public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface
this.surface = surface;
this.surfaceHolder = surfaceHolder;
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
options.add(":fullscreen");
}

public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface, int width,
Expand All @@ -70,6 +77,7 @@ public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface
this.height = height;
surfaceHolder = null;
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
options.add(":fullscreen");
}

public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface,
Expand All @@ -80,6 +88,11 @@ public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface
this.width = width;
this.height = height;
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
options.add(":fullscreen");
}

public void setOptions(ArrayList<String> options) {
this.options = options;
}

public boolean isPlaying() {
Expand Down Expand Up @@ -111,7 +124,11 @@ private void setMedia(Media media) {
//delay = network buffer + file buffer
//media.addOption(":network-caching=" + Constants.BUFFER);
//media.addOption(":file-caching=" + Constants.BUFFER);
media.addOption(":fullscreen");
if (options != null) {
for (String s : options) {
media.addOption(s);
}
}
media.setHWDecoderEnabled(true, false);
player = new MediaPlayer(vlcInstance);
player.setMedia(media);
Expand Down

0 comments on commit 4efa0ae

Please sign in to comment.