#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h>
#include <thread>
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, "/Users/user/Downloads/1.mp3");
// 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(100);//play the audio 100s
std::this_thread::sleep_for(std::chrono::milliseconds(100));
// stop playing
libvlc_media_player_stop(mp);
// free the media_player
libvlc_media_player_release(mp);
libvlc_release(inst);
return 0;
}
* thread #1: tid = 0xdb0b0, 0x00007fff95fc8434 libsystem_pthread.dylib`pthread_mutex_lock, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x28)
frame #0: 0x00007fff95fc8434 libsystem_pthread.dylib`pthread_mutex_lock
libsystem_pthread.dylib`pthread_mutex_lock:
-> 0x7fff95fc8434 <+0>: cmpq $0x4d55545a, (%rdi)
0x7fff95fc843b <+7>: jne 0x7fff95fc8494 ; <+96>
0x7fff95fc843d <+9>: leaq 0x1f(%rdi), %r8
0x7fff95fc8441 <+13>: andq $-0x8, %r8