【发布时间】:2020-02-28 15:36:40
【问题描述】:
我正在创建一个安卓播放器来播放 youtube 直播。我的要求是在 VLC org.videolan.libvlc.util.VLCVideoLayout 中播放流。
我遵循了示例应用程序https://code.videolan.org/videolan/libvlc-android-samples。
当我尝试播放 youtube 视频时,它没有播放,只是空白屏幕。
我使用了以下代码。
1.在布局xml文件中
<org.videolan.libvlc.util.VLCVideoLayout
android:id="@+id/vlc_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:keepScreenOn="true"
android:fitsSystemWindows="false"
/>
2。在活动课中
final ArrayList<String> args = new ArrayList<>();
args.add("--no-drop-late-frames");
args.add("--no-skip-frames");
args.add("--rtsp-tcp");
args.add("-vvv");
mLibVLC = new LibVLC(this, args);
mMediaPlayer = new MediaPlayer(mLibVLC);
mVideoLayout = findViewById(R.id.vlc_layout);
mMediaPlayer.attachViews(mVideoLayout, null, ENABLE_SUBTITLES, USE_TEXTURE_VIEW);
String url = "https://www.youtube.com/watch?v=H9mXFeGsGEE";
final Media media = new Media(mLibVLC, Uri.parse(url));
mMediaPlayer.setMedia(media);
media.release();
mMediaPlayer.play();
- 分级文件
repositories {
google()
maven {
url "https://dl.bintray.com/videolan/Android"
}
jcenter()
}
dependencies {
implementation 'org.videolan.android:libvlc-all:3.2.0'
}
- 如果我们提供任何其他流 url (hls),它可以工作。但是 youtube 视频就没有运气了。
谁能帮忙解决?
【问题讨论】:
标签: java android youtube libvlc vlc-android