Skip to content

Commit 4efa0ae

Browse files
committed
add options to player
1 parent 6031709 commit 4efa0ae

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# vlc-example-streamplayer
22

33
[![Release](https://jitpack.io/v/pedroSG94/vlc-example-streamplayer.svg)](https://jitpack.io/#pedroSG94/vlc-example-streamplayer)
4+
45
Example code how to play a stream with VLC.
56

67
Use this endpoint for test:

pedrovlc/src/main/java/com/pedro/vlc/VlcVideoLibrary.java

+18-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.view.SurfaceHolder;
88
import android.view.SurfaceView;
99
import android.view.TextureView;
10+
import java.util.ArrayList;
1011
import org.videolan.libvlc.IVLCVout;
1112
import org.videolan.libvlc.LibVLC;
1213
import org.videolan.libvlc.Media;
@@ -28,30 +29,35 @@ public class VlcVideoLibrary implements MediaPlayer.EventListener {
2829
private SurfaceTexture surfaceTexture;
2930
private Surface surface;
3031
private SurfaceHolder surfaceHolder;
32+
private ArrayList<String> options = new ArrayList<>();
3133

3234
public VlcVideoLibrary(Context context, VlcListener vlcListener, SurfaceView surfaceView) {
3335
this.vlcListener = vlcListener;
3436
this.surfaceView = surfaceView;
3537
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
38+
options.add(":fullscreen");
3639
}
3740

3841
public VlcVideoLibrary(Context context, VlcListener vlcListener, TextureView textureView) {
3942
this.vlcListener = vlcListener;
4043
this.textureView = textureView;
4144
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
45+
options.add(":fullscreen");
4246
}
4347

4448
public VlcVideoLibrary(Context context, VlcListener vlcListener, SurfaceTexture surfaceTexture) {
4549
this.vlcListener = vlcListener;
4650
this.surfaceTexture = surfaceTexture;
4751
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
52+
options.add(":fullscreen");
4853
}
4954

5055
public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface) {
5156
this.vlcListener = vlcListener;
5257
this.surface = surface;
5358
surfaceHolder = null;
5459
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
60+
options.add(":fullscreen");
5561
}
5662

5763
public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface,
@@ -60,6 +66,7 @@ public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface
6066
this.surface = surface;
6167
this.surfaceHolder = surfaceHolder;
6268
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
69+
options.add(":fullscreen");
6370
}
6471

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

7583
public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface,
@@ -80,6 +88,11 @@ public VlcVideoLibrary(Context context, VlcListener vlcListener, Surface surface
8088
this.width = width;
8189
this.height = height;
8290
vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
91+
options.add(":fullscreen");
92+
}
93+
94+
public void setOptions(ArrayList<String> options) {
95+
this.options = options;
8396
}
8497

8598
public boolean isPlaying() {
@@ -111,7 +124,11 @@ private void setMedia(Media media) {
111124
//delay = network buffer + file buffer
112125
//media.addOption(":network-caching=" + Constants.BUFFER);
113126
//media.addOption(":file-caching=" + Constants.BUFFER);
114-
media.addOption(":fullscreen");
127+
if (options != null) {
128+
for (String s : options) {
129+
media.addOption(s);
130+
}
131+
}
115132
media.setHWDecoderEnabled(true, false);
116133
player = new MediaPlayer(vlcInstance);
117134
player.setMedia(media);

0 commit comments

Comments
 (0)