Could not play youtube video

VLC for Android and Chrome OS specific usage questions
sanmool
Blank Cone
Blank Cone
Posts: 20
Joined: 02 Apr 2023 12:01

Could not play youtube video

Postby sanmool » 02 Apr 2023 12:22

Hello,

Currently, I am developing video player for android using Qt. I could play a media over internet server(https://OOO.avi) with no problem. However I could not play youtube video. VLC for Android version 3.5.4(2023-02-20) could play youtube.(The version 3.5.3 could not). So I used the libvlc extracted from that .apk file. But I could not play youtube.

I created media by
libvlc_media_t* p_md = libvlc_media_new_location( libvlc_instance, "https://www.youtube.com/watch?v=Jd2gBcwOWkE");
And I tried to get the subItem of p_md using

Code: Select all

libvlc_media_t *PlayerBase::get_sub_media(libvlc_media_t *p_md) { if( !p_md ) return nullptr; libvlc_media_parse(p_md); libvlc_media_list_t* sub_items = libvlc_media_subitems( p_md ); libvlc_media_t* sub_item = nullptr; int sub_items_count = -1; if( sub_items ){ libvlc_media_list_lock( sub_items ); sub_items_count = libvlc_media_list_count( sub_items ); for( int i = 0; i < sub_items_count; ++i ) { sub_item = libvlc_media_list_item_at_index( sub_items, i ); if (sub_item) break; } libvlc_media_list_unlock( sub_items ); libvlc_media_list_release( sub_items ); } return sub_item; }
But I always got sub_items_count = 0.
Do I have to something else.
Thank you for reading my question.

sanmool
Blank Cone
Blank Cone
Posts: 20
Joined: 02 Apr 2023 12:01

Re: Could not play youtube video

Postby sanmool » 06 Apr 2023 21:51

I replaced libvlc_media_parse(p_md); by
libvlc_media_parse_with_options(p_md, libvlc_media_parse_network, -1);
and it produced the following result.

[00007feed4000c20] main input debug: Creating an input for preparsing 'watch?v=rQOshUfYe6c'
[00007feecc000cb0] main meta fetcher debug: looking for meta fetcher module matching "any": 1 candidates
[00007feecc000cb0] lua meta fetcher debug: Trying Lua scripts in /home/jan/.local/share/vlc/lua/meta/fetcher
[00007feecc000cb0] lua meta fetcher debug: Trying Lua playlist script /home/jan/.local/share/vlc/lua/meta/fetcher/youtube.lua
[00007feecc000cb0] lua meta fetcher debug: skipping script (unmatched scope) /home/jan/.local/share/vlc/lua/meta/fetcher/youtube.lua
[00007feecc000cb0] lua meta fetcher debug: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/fetcher
...
where youtube.lua is the file I extracted from VLC-Android-3.5.4-armeabi-v7a.apk

My guess is that libvlc did not parse libvlc_media_t properly because it skips reading youtube.lua. Any idea what (unmatched scope) means and how to fix it?

Lotesdelere
Cone Master
Cone Master
Posts: 9961
Joined: 08 Sep 2006 04:39
Location: Europe

Re: Could not play youtube video

Postby Lotesdelere » 07 Apr 2023 09:49

where youtube.lua is the file I extracted from VLC-Android-3.5.4-armeabi-v7a.apk

Always get the latest up to date youtube.lua from there:
https://github.com/videolan/vlc/blob/ma ... outube.lua

sanmool
Blank Cone
Blank Cone
Posts: 20
Joined: 02 Apr 2023 12:01

Re: Could not play youtube video

Postby sanmool » 11 Apr 2023 23:57

Thank you Lotesdelere for your reply,

I made it work by adding code sleeping for 5 seconds.
//libvlc_media_parse(p_md);
libvlc_media_parse_with_options(p_md, libvlc_media_parse_network, -1);
sleefor(5); //sleep for 5 seconds.
Now I can play youtube on linux machine.

But I still could not play on Android build(It still returns sub_items_count = 0 on Android). I put youtube.lua on android-apk-file-root/assets/lua/playlist in my apk file. That is the same location as in VLC-Android-3.5.4-armv7.apk(from https://code.videolan.org/videolan/vlc-android) which plays youtube well. It may not read youtube.lua file in my apk.

Another thing I noticed is that, in youtube.lua file, I see vlc.peek( len ) which seems has the corresponding C/C++ code but I could not find it in libvlc source code under vlc-3.0.18/lib. I feel this is quite strange.

Lotesdelere
Cone Master
Cone Master
Posts: 9961
Joined: 08 Sep 2006 04:39
Location: Europe

Re: Could not play youtube video

Postby Lotesdelere » 12 Apr 2023 10:58

Moved to the Android forum.


Return to “VLC for Android and Chrome OS”

Who is online

Users browsing this forum: No registered users and 51 guests