[Ubuntu 22.04 x86_64] Newbie can not open m3u in simple C

This forum is about all development around libVLC.
emanuel
New Cone
New Cone
Posts: 5
Joined: 21 Aug 2024 01:20

[Ubuntu 22.04 x86_64] Newbie can not open m3u in simple C

Postby emanuel » 21 Aug 2024 01:31

Hello community,
I'm brand new to libvlc. I try in vain to open a simple m3u, but I can't.
The m3u opens with vlc, it's not the file.
I can also build and play a pls using "libvlc_media_list_add_media".
But not with an m3u, like in the vlc. :roll:

Please help me. Thanks in advance.

Code: Select all

/* VLC media player 3.0.16 Vetinari (revision 3.0.13-8-g41878ff4f2) */ /* cc example-playlist.c -lvlc -o example -I vlc/plugins */ #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <syslog.h> #include <string.h> #include <unistd.h> #include <vlc/vlc.h> //#define STATIC_ITEMS #define P_CHECK(V, A) do { \ if ((V) == NULL) { \ syslog(LOG_ERR, "%s at %s (%d): %s", #V, __FILE__, __LINE__, strerror(errno)); \ A; \ } \ } while (0); void err() { printf(">>> ERROR: var is NULL!\n"); } int main(int argc, char* argv[]) { (void) argc; (void) argv; libvlc_instance_t * inst = NULL; libvlc_media_player_t *mp = NULL; libvlc_media_list_player_t *mlp = NULL; libvlc_media_t *m = NULL; libvlc_media_list_t *ml = NULL; /* Load the VLC engine */ static const char *const args[] = { "--verbose=2" /* full log */ }; inst = libvlc_new (sizeof(args) / sizeof(*args) , args); /* Create a new item(s) */ m = libvlc_media_new_path (inst, "test.m3u"); //m = libvlc_media_new_location (inst, "file:///home/emanuel/C/libVlc/test.m3u"); P_CHECK(m, err); printf(">>> libvlc_media_parse_with_options %d\n", libvlc_media_parse_with_options (m, libvlc_media_parse_local | libvlc_media_parse_network, 10000)); printf(">>> libvlc_media_get_type %d\n", libvlc_media_get_type (m)); printf(">>> libvlc_media_get_state %d\n", libvlc_media_get_state (m)); printf(">>> libvlc_media_get_parsed_status %d\n", libvlc_media_get_parsed_status (m)); /* Create a new media_list */ ml = libvlc_media_subitems (m); P_CHECK(ml, err); /* No need to keep the media now */ libvlc_media_release (m); if(libvlc_media_list_count (ml)) printf(">>> media_list has got %d items\n", libvlc_media_list_count (ml)); else printf(">>> ERROR: emty media_list\n"); /* Create the media players */ mlp = libvlc_media_list_player_new (inst); P_CHECK(mlp, err); mp = libvlc_media_player_new (inst); P_CHECK(mp, err); libvlc_media_list_player_set_media_player (mlp, mp); libvlc_media_list_player_set_media_list (mlp, ml); libvlc_media_list_player_set_playback_mode (mlp, libvlc_playback_mode_default); /* Start playing */ libvlc_media_list_player_play (mlp); if(libvlc_media_list_player_is_playing (mlp)) printf(">>> libvlc_list_player is playing\n"); else printf(">>> ERROR: libvlc_list_player is not playing\n"); sleep (30); /* Stop playing */ libvlc_media_list_player_stop (mlp); /* Free the media players */ libvlc_media_list_player_release (mlp); libvlc_media_player_release (mp); /* Free the media_list */ libvlc_media_list_release (ml); /* Free the libvlc inst */ libvlc_release (inst); return 0; }
Last edited by emanuel on 21 Aug 2024 01:44, edited 3 times in total.

emanuel
New Cone
New Cone
Posts: 5
Joined: 21 Aug 2024 01:20

Re: [Ubuntu 22.04] Newbie can not open m3u in simple C

Postby emanuel » 21 Aug 2024 01:36

logfile:

Code: Select all

[000055b29c129430] main libvlc debug: VLC media player - 3.0.16 Vetinari [000055b29c129430] main libvlc debug: Copyright © 1996-2021 the VideoLAN team [000055b29c129430] main libvlc debug: revision 3.0.13-8-g41878ff4f2 [000055b29c129430] main libvlc debug: configured with ./configure '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--disable-debug' '--config-cache' '--disable-update-check' '--enable-fast-install' '--docdir=/usr/share/doc/vlc' '--with-binary-version=3.0.16-1build7' '--enable-a52' '--enable-aa' '--enable-aribsub' '--enable-avahi' '--enable-bluray' '--enable-caca' '--enable-chromaprint' '--enable-chromecast' '--enable-dav1d' '--enable-dbus' '--enable-dca' '--enable-dvbpsi' '--enable-dvdnav' '--enable-faad' '--enable-flac' '--enable-fluidsynth' '--enable-freetype' '--enable-fribidi' '--enable-gles2' '--enable-gnutls' '--enable-harfbuzz' '--enable-jack' '--enable-kate' '--enable-libass' '--enable-libmpeg2' '--enable-libxml2' '--enable-lirc' '--enable-mad' '--enable-matroska' '--enable-mod' '--enable-mpc' '--enable-mpg123' '--enable-mtp' '--enable-ncurses' '--enable-notify' '--enable-ogg' '--enable-opus' '--enable-pulse' '--enable-qt' '--enable-realrtsp' '--enable-samplerate' '--enable-sdl-image' '--enable-sftp' '--enable-shine' '--enable-shout' '--enable-skins2' '--enable-sndio' '--enable-soxr' '--enable-spatialaudio' '--enable-speex' '--enable-svg' '--enable-svgdec' '--enable-taglib' '--enable-theora' '--enable-twolame' '--enable-upnp' '--enable-vdpau' '--enable-vnc' '--enable-vorbis' '--enable-x264' '--enable-x265' '--enable-zvbi' '--with-kde-solid=/usr/share/solid/actions/' '--disable-aom' '--disable-crystalhd' '--disable-d3d11va' '--disable-decklink' '--disable-directx' '--disable-dsm' '--disable-dxva2' '--disable-fdkaac' '--disable-fluidlite' '--disable-freerdp' '--disable-goom' '--disable-gst-decode' '--disable-libtar' '--disable-live555' '--disable-macosx' '--disable-macosx-avfoundation' '--disable-macosx-qtkit' '--disable-mfx' '--disable-microdns' '--disable-opencv' '--disable-projectm' '--disable-schroedinger' '--disable-sparkle' '--disable-srt' '--disable-telx' '--disable-vpx' '--disable-vsxu' '--disable-wasapi' '--enable-alsa' '--enable-dc1394' '--enable-dv1394' '--enable-libplacebo' '--enable-linsys' '--enable-nfs' '--enable-udev' '--enable-v4l2' '--enable-wayland' '--enable-libva' '--enable-vcd' '--enable-smbclient' '--disable-oss' '--enable-mmx' '--enable-sse' '--disable-neon' '--disable-altivec' '--disable-omxil' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -ffile-prefix-map=/build/vlc-hoXXw1/vlc-3.0.16=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security ' 'LDFLAGS=-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -ffile-prefix-map=/build/vlc-hoXXw1/vlc-3.0.16=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security ' 'OBJCFLAGS=-g -O2 -ffile-prefix-map=/build/vlc-hoXXw1/vlc-3.0.16=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security' main libvlc debug: searching plug-in modules main libvlc debug: loading plugins cache file /usr/lib/x86_64-linux-gnu/vlc/plugins/plugins.dat main libvlc debug: recursively browsing `/usr/lib/x86_64-linux-gnu/vlc/plugins' main libvlc debug: plug-ins loaded: 519 modules main logger debug: looking for logger module matching "any": 4 candidates main logger debug: using logger module "console" main libvlc debug: translation test: code is "C" main keystore debug: looking for keystore module matching "memory": 4 candidates main keystore debug: using keystore module "memory" main libvlc debug: CPU has capabilities MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 FPU >>> libvlc_media_parse_with_options 0 >>> libvlc_media_get_type 1 >>> libvlc_media_get_state 0 >>> libvlc_media_get_parsed_status 0 main input debug: Creating an input for preparsing 'test.m3u' >>> ERROR: emty media_list main meta fetcher debug: looking for meta fetcher module matching "any": 1 candidates main generic debug: creating audio output main audio output debug: looking for audio output module matching "any": 6 candidates lua meta fetcher debug: Trying Lua scripts in /home/emanuel/.local/share/vlc/lua/meta/fetcher lua meta fetcher debug: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/fetcher lua meta fetcher debug: Trying Lua scripts in /usr/share/vlc/lua/meta/fetcher main meta fetcher debug: no meta fetcher modules matched main art finder debug: looking for art finder module matching "any": 2 candidates vlcpulse audio output debug: using library version 15.99.0 vlcpulse audio output debug: (compiled with version 15.99.0, protocol 35) lua art finder debug: Trying Lua scripts in /home/emanuel/.local/share/vlc/lua/meta/art lua art finder debug: Trying Lua scripts in /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art lua art finder debug: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/00_musicbrainz.luac lua art finder debug: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/00_musicbrainz.luac lua art finder debug: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/01_googleimage.luac lua art finder debug: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/01_googleimage.luac lua art finder debug: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/02_frenchtv.luac lua art finder debug: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/02_frenchtv.luac lua art finder debug: Trying Lua playlist script /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/03_lastfm.luac lua art finder debug: skipping script (unmatched scope) /usr/lib/x86_64-linux-gnu/vlc/lua/meta/art/03_lastfm.luac lua art finder debug: Trying Lua scripts in /usr/share/vlc/lua/meta/art main art finder debug: no art finder modules matched vlcpulse audio output debug: connected locally to /run/user/1000/pulse/native as client #60 vlcpulse audio output debug: using protocol 35, server protocol 35 pulse audio output debug: adding sink 0: alsa_output.pci-0000_00_1b.0.analog-stereo (Eingebautes Tongerät Analog Stereo) main audio output debug: using audio output module "pulse" main generic debug: keeping audio output main generic debug: creating audio output main audio output debug: looking for audio output module matching "any": 6 candidates vlcpulse audio output debug: using library version 15.99.0 vlcpulse audio output debug: (compiled with version 15.99.0, protocol 35) vlcpulse audio output debug: connected locally to /run/user/1000/pulse/native as client #61 vlcpulse audio output debug: using protocol 35, server protocol 35 pulse audio output debug: adding sink 0: alsa_output.pci-0000_00_1b.0.analog-stereo (Eingebautes Tongerät Analog Stereo) main audio output debug: using audio output module "pulse" main generic debug: keeping audio output main audio output debug: removing module "pulse" >>> ERROR: libvlc_list_player is not playing main audio output debug: removing module "pulse" main libvlc debug: exiting main libvlc debug: no exit handler main libvlc debug: removing all interfaces main keystore debug: removing module "memory"

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: [Ubuntu 22.04 x86_64] Newbie can not open m3u in simple C

Postby Rémi Denis-Courmont » 21 Aug 2024 09:03

You're ending playback before VLC has had time to even parse the playlist.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

emanuel
New Cone
New Cone
Posts: 5
Joined: 21 Aug 2024 01:20

Re: [Ubuntu 22.04 x86_64] Newbie can not open m3u in simple C

Postby emanuel » 21 Aug 2024 09:35

Ok, thanks for the answer. How can I change that? can I solve this with a callback or with sleep? Sorry, I'm still a newbie.

emanuel
New Cone
New Cone
Posts: 5
Joined: 21 Aug 2024 01:20

Re: [Ubuntu 22.04 x86_64] Newbie can not open m3u in simple C

Postby emanuel » 21 Aug 2024 09:38

Code: Select all

m = libvlc_media_new_path (inst, "test.m3u"); //m = libvlc_media_new_location (inst, "file:///home/emanuel/C/libVlc/test.m3u"); P_CHECK(m, err); printf(">>> libvlc_media_parse_with_options %d\n", libvlc_media_parse_with_options (m, libvlc_media_parse_local | libvlc_media_parse_network, 10000)); sleep (10);
this is working nice :mrgreen:

emanuel
New Cone
New Cone
Posts: 5
Joined: 21 Aug 2024 01:20

Re: [Ubuntu 22.04 x86_64] Newbie can not open m3u in simple C

Postby emanuel » 21 Aug 2024 10:07

This code works better:

Code: Select all

while (libvlc_media_get_parsed_status (m) != 4) { printf("*"); usleep (1000); }
but is that the correct way?


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 23 guests