private SurfaceView mSurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R. layout.activity_main);✅
// Get SurfaceView from layout
mSurfaceView = findViewById(R. id.surface_view);✅
// Set SurfaceView as video output
mMediaPlayer.getVLCVout().setVideoView(mSurfaceView);
mMediaPlayer.getVLCVout().attachViews();
}
设置媒体源:使用MediaPlayer实例设置要播放的媒体源。可以使用以下代码设置媒体源:
private Media mMedia = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R. layout.activity_main);✅
// Create Media instance
Uri uri = Uri.parse("your_media_url");
mMedia = new Media(mLibVLC, uri);
// Set media to MediaPlayer
mMediaPlayer.setMedia(mMedia);
}
要将VLC Media Player集成到Android应用程序中,可以按照以下步骤进行操作:
这些步骤将帮助您将VLC Media Player集成到Android应用程序中,并实现视频播放功能。
Learn more: