欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在自己的项目中使用VLC-Android

程序员文章站 2022-04-29 16:44:19
...

先将编译好的aar包放到app/libs目录下
以下为一个简单的示例

import org.videolan.libvlc.IVLCVout;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaPlayer;
public class VLCVideo extends AppCompatActivity {
    private LibVLC libVLC=null;
    private SurfaceView surfaceView=null;
    private MediaPlayer mediaPlayer=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vlcvideo);
        surfaceView= (SurfaceView) findViewById(R.id.surfaceView);
        ArrayList<String> options=new ArrayList<>();
        options.add("-vvv");
        libVLC=new LibVLC(this,options);
        mediaPlayer=new MediaPlayer(libVLC);
        IVLCVout ivlcVout=mediaPlayer.getVLCVout();
        ivlcVout.setVideoView(surfaceView);
        ivlcVout.attachViews();
        Media media=new Media(libVLC,Uri.parse("rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov") );
        mediaPlayer.setMedia(media);
        mediaPlayer.play();
    }
}

参考:
https://blog.csdn.net/djstavav/article/details/71576807
https://blog.csdn.net/lp8800/article/details/62221092