确保您已安装以下软件包(否则安装它):
$apt-get install libvlccore-dev libvlc-dev
test.c的:
#include
#include
#include
int main(int argc, char **argv)
{
libvlc_instance_t *inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;
// load the vlc engine
inst = libvlc_new(0, NULL);
// create a new item
m = libvlc_media_new_path(inst, "path to MP3 file");
// create a media play playing environment
mp = libvlc_media_player_new_from_media(m);
// no need to keep the media now
libvlc_media_release(m);
// play the media_player
libvlc_media_player_play(mp);
sleep(10);
// stop playing
libvlc_media_player_stop(mp);
// free the media_player
libvlc_media_player_release(mp);
libvlc_release(inst);
return 0;
}
如何链接和编译:
$gcc $(pkg-config --cflags libvlc) -c test.c -o test.o
$gcc test.o -o test $(pkg-config --libs libvlc)