Play youtube video on Android using libvlc

This forum is about all development around libVLC.
whd2
New Cone
New Cone
Posts: 3
Joined: 12 Feb 2021 19:20

Play youtube video on Android using libvlc

Postby whd2 » 12 Feb 2021 19:27

I found this piece of code https://code.videolan.org/videolan/LibV ... tube-video
and tried to do the same thing on android

Code: Select all

if(sourceUrl.contains("youtube")) { final Uri uri = Uri.parse(sourceUrl); final Media nm = new Media(mLibVLC, uri ); nm .parse(0x04); nm .release(); MediaList mediaList = nm .subItems(); mediaList.release(); Media nMedia = mediaList.getMediaAt(0); nMedia.release(); nMedia.setHWDecoderEnabled(hwDecoderEnabled, false); mMediaPlayer.setMedia(nMedia);
but it ends with following exception being thrown

Code: Select all

Caused by: java.lang.IllegalStateException: can't get VLCObject instance at org.videolan.libvlc.MediaList.nativeNewFromMedia(Native Method) at org.videolan.libvlc.MediaList.<init>(MediaList.java:104) at org.videolan.libvlc.Media.subItems(Media.java:572)
Not sure exactly why it is happening

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: Play youtube video on Android using libvlc

Postby mfkl » 15 Feb 2021 03:35

don't release objects before using them.
https://mfkl.github.io


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 22 guests