2

I was creating an android player to play youtube live streams. My requirement is to play the stream in VLC org.videolan.libvlc.util.VLCVideoLayout. I followed the sample aplication https://code.videolan.org/videolan/libvlc-android-samples. When I tried to play youtube videos, it is not playing but only blank screen.

I used the following code.

1. In layout xml file

<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. In activity class

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();
  1. gradel file

repositories {
    google()
    maven {
        url "https://dl.bintray.com/videolan/Android"
    }
    jcenter()
}
dependencies {
    implementation 'org.videolan.android:libvlc-all:3.2.0'
}
  1. If we give any other streaming url (hls), it works. But no luck with youtube videos.

Could anyone help to solve it ?

Prince Francis
  • 2,995
  • 1
  • 14
  • 22

1 Answers1

1

For youtube videos, you have to parse the media and then play one of its sub items.

mfkl
  • 1,914
  • 1
  • 11
  • 21
  • If I give the youtube url directly in the VLC player, it works. So I think there is a way in `libVLC` too. I am able to open VLC player from application with the youtube url. But no luck with libVLC. – Prince Francis Nov 04 '19 at 06:08
  • I just told you the way to do it with libvlc – mfkl Nov 04 '19 at 10:08
  • https://code.videolan.org/videolan/LibVLCSharp/issues/156#note_35657 – mfkl Nov 04 '19 at 10:08