libvlc
libvlc copied to clipboard
vlc for android, easy to use
libvlc
vlc for android
The package of libvlc makes it easier to use
Lastest:
Build with libvlc:3.2.5
Quick Start
1. Add library to your project:
Add jitpack.io repository to your root build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add library to dependencies
dependencies {
implementation 'com.github.mafanwei:libvlc:Tag'
}
Usage
Basic usage.
Use VlcVideoLibrary.Builder to build VlcVideoLibrary.
And use VlcVideoLibrary to play.
VlcVideoLibrary.Builder builder = new VlcVideoLibrary.Builder(this, true);
//set a render object: Surface/SurfaceView/TextureView/SurfaceTexture
builder.setSurfaceView(surfaceView);
//create VlcVideoLibrary.
VlcVideoLibrary vlcVideoLibrary = builder.create();
//set play url, such as a rtsp.
vlcVideoLibrary.setPlayUrl("rtsp://192.168.31.192:1234");
//set output.
vlcVideoLibrary.setVlcVout();
//now start play:
vlcVideoLibrary.startPlay();
VlcVideoLibrary Builder
VlcVideoLibrary.Builder has some apis to help you.
| name | description |
|---|---|
| setWidth | set the pixel width of the video |
| setHeight | set the pixel height of the video |
| setScaleType | set the video scale type, by default, scaletype is set to ScaleType.SURFACE_BEST_FIT |
| setSurface | set a render Surface |
| setSurfaceView | set a render SurfaceView |
| setTextureView | set a render TextureView |
| setSurfaceTexture | set a render surfaceTexture |
| useFullScreen | make video full screen |
| useNoCache | make the video not use cache |
| useRtspTcp | it can make rtsp playback more stable, but not all streaming devices support it |
| addOption | if you know the parameters of libvlc, you can use it add some options you want |
| setOptions | set libvlc options |
| removeOption | remove some options you want |
| clearOptions | clear all options |
| setAutoSize | if true make video auto size |
| setVlcListener | set a listener to notice what happened on libvlc |
For more apis, please download code.
Donate
Buy a cup of coffee for the author.
Other
If you have good ideas, please discuss with me. Pull request is always welcome.