Differenze tra le versioni di "Eseguire file audio mediante le funzioni esterne del API di VLC"
(20 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 8: | Riga 8: | ||
E' possibile eseguire dati audio anche direttamente da internet. | E' possibile eseguire dati audio anche direttamente da internet. | ||
− | + | Per creare in Gambas un'applicazione con la presente risorsa, si dovrà installare e richiamare la libreria condivisa "''libvlc.so.5.6.1'' ". | |
− | Per creare in Gambas un'applicazione con la presente risorsa, si dovrà installare e richiamare la libreria | ||
===Esempio con applicazione grafica=== | ===Esempio con applicazione grafica=== | ||
Riga 17: | Riga 16: | ||
− | Library "libvlc:5. | + | Library "libvlc:5.6.1" |
Private Enum libvlc_NothingSpecial = 0, | Private Enum libvlc_NothingSpecial = 0, | ||
− | + | libvlc_Opening, | |
− | + | libvlc_Buffering, | |
− | + | libvlc_Playing, | |
− | + | libvlc_Paused, | |
− | + | libvlc_Stopped, | |
− | + | libvlc_Ended, | |
− | + | libvlc_Error | |
<FONT color=gray>' ''libvlc_instance_t * libvlc_new (int argc, const char *const *argv)'' | <FONT color=gray>' ''libvlc_instance_t * libvlc_new (int argc, const char *const *argv)'' | ||
Riga 50: | Riga 49: | ||
<FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *)'' | <FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *)'' | ||
' ''Get the current movie length (in ms).''</font> | ' ''Get the current movie length (in ms).''</font> | ||
− | Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As | + | Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As Long |
<FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | <FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | ||
' ''Get the current movie time (in ms).''</font> | ' ''Get the current movie time (in ms).''</font> | ||
− | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As | + | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long |
<FONT color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | <FONT color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | ||
Riga 67: | Riga 66: | ||
' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ||
Private Extern libvlc_media_player_release(p_mi As Pointer) | Private Extern libvlc_media_player_release(p_mi As Pointer) | ||
+ | |||
+ | <FONT color=gray>' ''void libvlc_media_release (libvlc_media_t *p_md)'' | ||
+ | ' ''Decrement the reference count of a media descriptor object.''</font> | ||
+ | Private Extern libvlc_media_release(p_md As Pointer) | ||
<FONT color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | <FONT color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | ||
Riga 73: | Riga 76: | ||
− | + | Public Sub Button1_Click() | |
Dim m As Pointer | Dim m As Pointer | ||
− | |||
<FONT color=gray>' ''Inizializza la libreria VLC:''</font> | <FONT color=gray>' ''Inizializza la libreria VLC:''</font> | ||
− | + | inst = libvlc_new(0, Null) | |
<FONT color=gray>' ''Crea un nuovo oggetto multimedia:''</font> | <FONT color=gray>' ''Crea un nuovo oggetto multimedia:''</font> | ||
− | + | m = libvlc_media_new_path(inst, "<FONT color=darkgreen>''/percorso/del/file/audio''</font>") | |
<FONT color=gray>' ''Crea un media player:''</font> | <FONT color=gray>' ''Crea un media player:''</font> | ||
− | + | mp = libvlc_media_player_new_from_media(m) | |
+ | |||
+ | <FONT color=gray>' ''Chiude il descrittore dell'oggetto media:''</font> | ||
+ | libvlc_media_release(m) | ||
<FONT color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | <FONT color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | ||
− | + | libvlc_media_player_play(mp) | |
− | + | Repeat | |
− | + | TextLabel1.Text = "Durata: " & Str(Time(0, 0, 0, libvlc_media_player_get_length(mp, 0))) | |
− | + | TextLabel2.Text = "<FONT Color=red>" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) | |
− | + | Wait 0.01 | |
− | + | Until libvlc_media_player_get_state(mp) > libvlc_Paused | |
+ | |||
+ | <FONT color=gray>' ''Rilascia e chiude il media player:''</font> | ||
+ | libvlc_media_player_release(mp) | ||
− | + | <FONT color=gray>' ''Chiude la libreria VLC:''</font> | |
+ | libvlc_release(inst) | ||
− | + | End | |
− | + | Public Sub Button2_Click() | |
<FONT color=gray>' ''Arresta l'esecuzione del file audio:''</font> | <FONT color=gray>' ''Arresta l'esecuzione del file audio:''</font> | ||
− | + | libvlc_media_player_stop(mp) | |
− | |||
− | |||
− | |||
− | + | End | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Public Sub ToggleButton1_Click() | |
<FONT color=gray>' ''Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio:''</font> | <FONT color=gray>' ''Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio:''</font> | ||
− | + | libvlc_media_player_pause(mp) | |
− | + | End | |
− | |||
− | |||
In quest'altro esempio mostreremo un effetto video (''Spectrum analyzer'') di VLC, che rappresenta un "Analizzatore di spettro", all'interno di una ''DrawingArea'' | In quest'altro esempio mostreremo un effetto video (''Spectrum analyzer'') di VLC, che rappresenta un "Analizzatore di spettro", all'interno di una ''DrawingArea'' | ||
Private inst As Pointer | Private inst As Pointer | ||
Private mp As Pointer | Private mp As Pointer | ||
− | + | ||
− | Library "libvlc:5. | + | Library "libvlc:5.6.1" |
Private Enum libvlc_NothingSpecial = 0, | Private Enum libvlc_NothingSpecial = 0, | ||
− | + | libvlc_Opening, | |
− | + | libvlc_Buffering, | |
− | + | libvlc_Playing, | |
− | + | libvlc_Paused, | |
− | + | libvlc_Stopped, | |
− | + | libvlc_Ended, | |
− | + | libvlc_Error | |
<FONT color=gray>' ''libvlc_instance_t * libvlc_new (int argc, const char *const *argv)'' | <FONT color=gray>' ''libvlc_instance_t * libvlc_new (int argc, const char *const *argv)'' | ||
Riga 170: | Riga 166: | ||
<FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *)'' | <FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *)'' | ||
' ''Get the current movie length (in ms).''</font> | ' ''Get the current movie length (in ms).''</font> | ||
− | Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As | + | Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As Long |
<FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | <FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | ||
' ''Get the current movie time (in ms).''</font> | ' ''Get the current movie time (in ms).''</font> | ||
− | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As | + | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long |
<FONT color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | <FONT color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | ||
Riga 187: | Riga 183: | ||
' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ||
Private Extern libvlc_media_player_release(p_mi As Pointer) | Private Extern libvlc_media_player_release(p_mi As Pointer) | ||
+ | |||
+ | <FONT color=gray>' ''void libvlc_media_release (libvlc_media_t *p_md)'' | ||
+ | ' ''Decrement the reference count of a media descriptor object.''</font> | ||
+ | Private Extern libvlc_media_release(p_md As Pointer) | ||
<FONT color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | <FONT color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | ||
Riga 193: | Riga 193: | ||
− | + | Public Sub Button1_Click() | |
Dim ss As String[] | Dim ss As String[] | ||
Dim m As Pointer | Dim m As Pointer | ||
− | Dim | + | Dim id As Integer |
− | |||
− | |||
− | + | ss = ["--audio-visual=visual", "--effect-list=spectrum"] | |
<FONT color=gray>' ''Inizializza la libreria VLC:''</font> | <FONT color=gray>' ''Inizializza la libreria VLC:''</font> | ||
− | + | inst = libvlc_new(ss.Count, ss) | |
<FONT color=gray>' ''Crea un nuovo oggetto multimedia:''</font> | <FONT color=gray>' ''Crea un nuovo oggetto multimedia:''</font> | ||
− | + | m = libvlc_media_new_path(inst, "<FONT color=darkgreen>''/percorso/del/file/audio''</font>") | |
<FONT color=gray>' ''Crea un media player:''</font> | <FONT color=gray>' ''Crea un media player:''</font> | ||
− | + | mp = libvlc_media_player_new_from_media(m) | |
+ | |||
+ | <FONT color=gray>' ''Chiude il descrittore dell'oggetto media:''</font> | ||
+ | libvlc_media_release(m) | ||
<FONT color=gray>' ''Per far mostrare l'effetto video "Analizzatore di spettro" nella "DrawingArea", ricaviamo il suo identificativo:''</font> | <FONT color=gray>' ''Per far mostrare l'effetto video "Analizzatore di spettro" nella "DrawingArea", ricaviamo il suo identificativo:''</font> | ||
− | + | id = DrawingArea1.Id | |
<FONT color=gray>' ''Passiamo l'identificativo della finestra, nella quale dovrà essere mostrato l'effetto "Spectrum analyzer":''</font> | <FONT color=gray>' ''Passiamo l'identificativo della finestra, nella quale dovrà essere mostrato l'effetto "Spectrum analyzer":''</font> | ||
− | + | libvlc_media_player_set_xwindow(mp, id) | |
<FONT color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | <FONT color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | ||
− | + | libvlc_media_player_play(mp) | |
− | + | Repeat | |
− | + | TextLabel1.Text = "Durata: " & Str(Time(0, 0, 0, libvlc_media_player_get_length(mp, 0))) | |
− | + | TextLabel2.Text = "<FONT Color=red>" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) | |
− | + | Wait 0.01 | |
− | + | Until libvlc_media_player_get_state(mp) > libvlc_Paused | |
− | + | <FONT color=gray>' ''Rilascia e chiude il media player:''</font> | |
+ | libvlc_media_player_release(mp) | ||
+ | |||
+ | <FONT color=gray>' ''Chiude la libreria VLC:''</font> | ||
+ | libvlc_release(inst) | ||
− | + | End | |
− | + | Public Sub Button2_Click() | |
<FONT color=gray>' ''Arresta l'esecuzione del file audio:''</font> | <FONT color=gray>' ''Arresta l'esecuzione del file audio:''</font> | ||
− | + | libvlc_media_player_stop(mp) | |
− | |||
− | |||
− | + | End | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Public Sub ToggleButton1_Click() | |
<FONT color=gray>' ''Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio:''</font> | <FONT color=gray>' ''Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio:''</font> | ||
− | + | libvlc_media_player_pause(mp) | |
− | + | End | |
− | |||
− | |||
Quest'altro esempio è più completo e complesso del precedente. La particolarità del codice seguente è che è possibile selezionare nel codice fino a 5 effetti grafici VLC. | Quest'altro esempio è più completo e complesso del precedente. La particolarità del codice seguente è che è possibile selezionare nel codice fino a 5 effetti grafici VLC. | ||
Private bt1 As Button | Private bt1 As Button | ||
Riga 269: | Riga 261: | ||
Private fileaudio As String | Private fileaudio As String | ||
Private inst As Pointer | Private inst As Pointer | ||
+ | Private m As Pointer | ||
Private mp As Pointer | Private mp As Pointer | ||
− | Library "libvlc:5. | + | Library "libvlc:5.6.1" |
Private Enum libvlc_NothingSpecial = 0, libvlc_Opening, libvlc_Buffering, libvlc_Playing, | Private Enum libvlc_NothingSpecial = 0, libvlc_Opening, libvlc_Buffering, libvlc_Playing, | ||
Riga 303: | Riga 296: | ||
<FONT Color=gray>' ''libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *)'' | <FONT Color=gray>' ''libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *)'' | ||
' ''Get the current movie length (in ms).''</font> | ' ''Get the current movie length (in ms).''</font> | ||
− | Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As | + | Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As Long |
<FONT Color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | <FONT Color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | ||
' ''Get the current movie time (in ms).''</font> | ' ''Get the current movie time (in ms).''</font> | ||
− | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As | + | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long |
<FONT Color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | <FONT Color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | ||
Riga 320: | Riga 313: | ||
' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ||
Private Extern libvlc_media_player_release(p_mi As Pointer) | Private Extern libvlc_media_player_release(p_mi As Pointer) | ||
+ | |||
+ | <FONT color=gray>' ''void libvlc_media_release (libvlc_media_t *p_md)'' | ||
+ | ' ''Decrement the reference count of a media descriptor object.''</font> | ||
+ | Private Extern libvlc_media_release(p_md As Pointer) | ||
<FONT Color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | <FONT Color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | ||
Riga 326: | Riga 323: | ||
− | + | Public Sub Form_Open() | |
Dim effetti, ss As String[] | Dim effetti, ss As String[] | ||
Dim argc As Integer | Dim argc As Integer | ||
− | + | GestioneOggetti() | |
− | + | effetti = ["dummy", "scope", "spectrum", "spectrometer", "vuMeter"] | |
− | + | ss = ["--audio", "--audio-visual=visual", "--effect-list=" & effetti[4], "--visual-80-bands", "--visual-peaks", | |
− | + | "--width= 350", "--height=250", "--gain=1.000", "--no-xli"] | |
<FONT Color=gray>' ''Indica quanti, e dunque, quali effetti, compresi nel vettore "ss" si vogliono utilizzare:''</font> | <FONT Color=gray>' ''Indica quanti, e dunque, quali effetti, compresi nel vettore "ss" si vogliono utilizzare:''</font> | ||
− | + | argc = ss.Count | |
<FONT Color=gray>' ''Inizializza la libreria VLC:''</font> | <FONT Color=gray>' ''Inizializza la libreria VLC:''</font> | ||
− | + | inst = libvlc_new(argc, ss) | |
− | + | End | |
− | + | Public Sub Button1_Click() | |
− | |||
Dim id As Integer | Dim id As Integer | ||
Dim DrAr As DrawingArea | Dim DrAr As DrawingArea | ||
− | + | With DrAr = New DrawingArea(Me) | |
− | + | .X = 10 | |
− | + | .Y = 10 | |
− | + | .W = 350 | |
− | + | .H = 250 | |
− | + | End With | |
− | + | bt1.Enabled = False | |
− | + | tb.Enabled = True | |
− | + | tb.Value = False | |
<FONT Color=gray>' ''Crea un nuovo oggetto multimedia.'' | <FONT Color=gray>' ''Crea un nuovo oggetto multimedia.'' | ||
' ''Nel secondo argomento della funzione va specificato il percorso del file audio.''</font> | ' ''Nel secondo argomento della funzione va specificato il percorso del file audio.''</font> | ||
− | + | m = libvlc_media_new_path(inst, fileaudio) | |
<FONT Color=gray>' ''Crea un media player:''</font> | <FONT Color=gray>' ''Crea un media player:''</font> | ||
− | + | mp = libvlc_media_player_new_from_media(m) | |
+ | |||
+ | <FONT color=gray>' ''Chiude l'oggetto media:''</font> | ||
+ | libvlc_media_release(m) | ||
<FONT Color=gray>' ''Per far mostrare l'effetto VLC nella "DrawingArea", ricaviamo il suo identificativo:''</font> | <FONT Color=gray>' ''Per far mostrare l'effetto VLC nella "DrawingArea", ricaviamo il suo identificativo:''</font> | ||
− | + | id = DrAr.Id | |
<FONT Color=gray>' ''Passiamo l'identificativo della finestra, nella quale dovrà essere mostrato l'effetto VLC:''</font> | <FONT Color=gray>' ''Passiamo l'identificativo della finestra, nella quale dovrà essere mostrato l'effetto VLC:''</font> | ||
− | + | libvlc_media_player_set_xwindow(mp, id) | |
<FONT Color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | <FONT Color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | ||
− | + | libvlc_media_player_play(mp) | |
− | + | Repeat | |
− | + | tl1.Text = "Durata: " & Str(Time(0, 0, 0, libvlc_media_player_get_length(mp, 0))) | |
− | + | tl2.Text = "<FONT Color=red>" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) | |
− | + | Wait 0.01 | |
− | + | Until libvlc_media_player_get_state(mp) > libvlc_Paused | |
− | + | mp = 0 | |
+ | bt1.Enabled = True | ||
− | + | End | |
− | + | Public Sub Button2_Click() | |
Stop() | Stop() | ||
− | + | End | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Public Sub ToggleButton1_Click() | |
<FONT Color=gray>' ''Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio:''</font> | <FONT Color=gray>' ''Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio:''</font> | ||
libvlc_media_player_pause(mp) | libvlc_media_player_pause(mp) | ||
− | + | End | |
− | + | Public Sub Form_Close() | |
If Object.IsValid(Me) Then Chiude() | If Object.IsValid(Me) Then Chiude() | ||
− | |||
− | |||
+ | End | ||
+ | |||
+ | |||
+ | Public Sub Menu_Click() | ||
− | |||
− | |||
Select Case Last.Name | Select Case Last.Name | ||
Case "Apri" | Case "Apri" | ||
With Dialog | With Dialog | ||
.Title = "Apre file..." | .Title = "Apre file..." | ||
− | .Filter = ["*.mp3; *.ogg; *.wav | + | .Filter = ["*.mp3; *.ogg; *.wav; *.wma", "File audio"] |
If .OpenFile() Then Return | If .OpenFile() Then Return | ||
fileaudio = .Path | fileaudio = .Path | ||
Riga 450: | Riga 430: | ||
Chiude() | Chiude() | ||
End Select | End Select | ||
+ | |||
+ | End | ||
+ | |||
+ | |||
+ | Private Procedure Chiude() | ||
+ | |||
+ | If mp > 0 Then | ||
+ | <FONT Color=gray>' ''Arresta l'esecuzione del file audio:''</font> | ||
+ | libvlc_media_player_stop(mp) | ||
+ | <FONT Color=gray>' ''Rilascia e chiude il media player:''</font> | ||
+ | libvlc_media_player_release(mp) | ||
+ | Endif | ||
+ | |||
+ | <FONT Color=gray>' ''Chiude la libreria VLC:''</font> | ||
+ | libvlc_release(inst) | ||
+ | |||
+ | If Object.IsValid(Me) Then | ||
+ | Object.Lock(Me) | ||
+ | Me.Close | ||
+ | Endif | ||
− | + | End | |
− | + | Private Procedure Stop() | |
If mp > 0 Then | If mp > 0 Then | ||
Riga 466: | Riga 466: | ||
tb.Value = False | tb.Value = False | ||
− | + | End | |
− | + | Private Procedure GestioneOggetti() | |
Dim mn1, mn2 As Menu | Dim mn1, mn2 As Menu | ||
− | + | With Me | |
− | + | .W = 400 | |
− | + | .H = 370 | |
− | + | End With | |
− | + | With tl0 = New TextLabel(Me) | |
− | + | .X = 10 | |
− | + | .Y = 265 | |
− | + | .W = 350 | |
− | + | .H = 20 | |
− | + | End With | |
− | + | With tl1 = New TextLabel(Me) | |
− | + | .X = 10 | |
− | + | .Y = tl0.Y + tl0.H | |
− | + | .W = 120 | |
− | + | .H = 18 | |
− | + | .Alignment = Align.Top | |
− | + | End With | |
− | + | With tl2 = New TextLabel(Me) | |
− | + | .X = tl1.X + tl1.W + 30 | |
− | + | .Y = tl0.Y + tl0.H | |
− | + | .W = 120 | |
− | + | .H = 18 | |
− | + | .Alignment = Align.TopLeft | |
− | + | End With | |
− | + | With bt1 = New Button(Me) As "Button1" | |
− | + | .X = 10 | |
− | + | .Y = 300 | |
− | + | .W = 300 | |
− | + | .H = 40 | |
− | + | .Foreground = Color.DarkGreen | |
− | + | .Text = "Esegui" | |
− | + | .Enabled = False | |
− | + | End With | |
− | + | With bt2 = New Button(Me) As "Button2" | |
− | + | .X = bt1.X + bt1.W + 20 | |
− | + | .Y = 300 | |
− | + | .W = 50 | |
− | + | .H = 40 | |
− | + | .Foreground = Color.DarkRed | |
− | + | .Text = "Stop" | |
− | + | End With | |
− | + | With tb = New ToggleButton(Me) As "ToggleButton1" | |
− | + | .X = bt2.X | |
− | + | .Y = 220 | |
− | + | .W = 50 | |
− | + | .H = 40 | |
− | + | .Text = "Pausa" | |
− | + | .Enabled = False | |
− | + | End With | |
− | + | With menu = New Menu(Me) As "Menu" | |
− | + | .Caption = "File" | |
− | + | End With | |
− | + | With mn1 = New Menu(menu, False) As "Menu" | |
.Caption = "Apri file..." | .Caption = "Apri file..." | ||
.Name = "Apri" | .Name = "Apri" | ||
− | + | End With | |
− | + | With mn2 = New Menu(menu, False) As "Menu" | |
.Caption = "Esci" | .Caption = "Esci" | ||
.Name = "Esci" | .Name = "Esci" | ||
− | + | End With | |
− | + | End | |
− | |||
− | |||
===Esempio con applicazione ''a riga di comando''=== | ===Esempio con applicazione ''a riga di comando''=== | ||
− | Library "libvlc:5. | + | Library "libvlc:5.6.1" |
Private Enum libvlc_NothingSpecial = 0, | Private Enum libvlc_NothingSpecial = 0, | ||
− | + | libvlc_Opening, | |
− | + | libvlc_Buffering, | |
− | + | libvlc_Playing, | |
− | + | libvlc_Paused, | |
− | + | libvlc_Stopped, | |
− | + | libvlc_Ended, | |
− | + | libvlc_Error | |
<FONT color=gray>' ''libvlc_instance_t * libvlc_new (int argc, const char *const *argv)'' | <FONT color=gray>' ''libvlc_instance_t * libvlc_new (int argc, const char *const *argv)'' | ||
Riga 568: | Riga 566: | ||
<FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | <FONT color=gray>' ''libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi)'' | ||
' ''Get the current movie time (in ms).''</font> | ' ''Get the current movie time (in ms).''</font> | ||
− | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As | + | Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long |
<FONT color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | <FONT color=gray>' ''libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi)'' | ||
' ''Get current movie state.''</font> | ' ''Get current movie state.''</font> | ||
− | Private Extern libvlc_media_player_get_state(p_mi As Pointer) As | + | Private Extern libvlc_media_player_get_state(p_mi As Pointer) As Long |
<FONT color=gray>' ''void libvlc_media_player_release (libvlc_media_player_t * p_mi)'' | <FONT color=gray>' ''void libvlc_media_player_release (libvlc_media_player_t * p_mi)'' | ||
' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ' ''Release a media_player after use Decrement the reference count of a media player object.''</font> | ||
Private Extern libvlc_media_player_release(p_mi As Pointer) | Private Extern libvlc_media_player_release(p_mi As Pointer) | ||
+ | |||
+ | <FONT color=gray>' ''void libvlc_media_release (libvlc_media_t *p_md)'' | ||
+ | ' ''Decrement the reference count of a media descriptor object.''</font> | ||
+ | Private Extern libvlc_media_release(p_md As Pointer) | ||
<FONT color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | <FONT color=gray>' ''libvlc_release (libvlc_instance_t * p_instance)'' | ||
Riga 583: | Riga 585: | ||
− | + | Public Sub Main() | |
− | Dim m | + | Dim inst, m, mp As Pointer |
<FONT color=gray>' ''Inizializza la libreria VLC:''</font> | <FONT color=gray>' ''Inizializza la libreria VLC:''</font> | ||
− | + | inst = libvlc_new(0, Null) | |
<FONT color=gray>' ''Crea un nuovo oggetto multimedia:''</font> | <FONT color=gray>' ''Crea un nuovo oggetto multimedia:''</font> | ||
− | + | m = libvlc_media_new_path(inst, "<FONT color=darkgreen>''/percorso/del/file/audio''</font>") | |
<FONT color=gray>' ''Crea un media player:''</font> | <FONT color=gray>' ''Crea un media player:''</font> | ||
− | + | mp = libvlc_media_player_new_from_media(m) | |
− | + | ||
+ | libvlc_media_release(m) | ||
+ | |||
<FONT color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | <FONT color=gray>' ''Avvia l'esecuzione del file audio da parte del media player:''</font> | ||
− | + | libvlc_media_player_play(mp) | |
− | |||
− | |||
− | |||
− | |||
+ | While libvlc_media_player_get_state(mp) < libvlc_Stopped | ||
+ | Write "\r" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) | ||
+ | Flush | ||
+ | White 0.01 | ||
+ | Wend | ||
<FONT color=gray>' ''Va in chiusura:''</font> | <FONT color=gray>' ''Va in chiusura:''</font> | ||
+ | libvlc_media_player_release(mp) | ||
+ | libvlc_release(inst) | ||
− | + | End | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Riga 620: | Riga 620: | ||
=Riferimenti= | =Riferimenti= | ||
* http://www.videolan.org/developers/vlc/doc/doxygen/html/index.html | * http://www.videolan.org/developers/vlc/doc/doxygen/html/index.html | ||
+ | * https://wiki.videolan.org/VLC_command-line_help/ |
Versione attuale delle 05:57, 14 gen 2024
La libreria LibVLC mette a disposizione funzioni e risorse anche per eseguire file audio.
I file audio eseguibili sono i seguenti:
- MP3;
- OGG;
- WAV;
- WMA.
E' possibile eseguire dati audio anche direttamente da internet.
Per creare in Gambas un'applicazione con la presente risorsa, si dovrà installare e richiamare la libreria condivisa "libvlc.so.5.6.1 ".
Esempio con applicazione grafica
Mostriamo di seguito un semplice esempio, nel quale si potrà avviare, arrestare, porre in pausa e riprendere l'esecuzione del file audio:
Private inst As Pointer Private mp As Pointer Library "libvlc:5.6.1" Private Enum libvlc_NothingSpecial = 0, libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, libvlc_Stopped, libvlc_Ended, libvlc_Error ' libvlc_instance_t * libvlc_new (int argc, const char *const *argv) ' Create And initialize a libvlc instance. Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer ' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path) ' Create a media for a certain file path. Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer ' libvlc_media_player_t * libvlc_media_player_new_from_media (libvlc_media_t *p_md) ' Create a Media Player object from a Media. Private Extern libvlc_media_player_new_from_media(p_md As Pointer) As Pointer ' int libvlc_media_player_play (libvlc_media_player_t * p_mi) ' Play the audio file. Private Extern libvlc_media_player_play(p_mi As Pointer) As Integer ' void libvlc_media_player_stop (libvlc_media_player_t * p_mi) ' Stop the audio file. Private Extern libvlc_media_player_stop(p_mi As Pointer) ' libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *) ' Get the current movie length (in ms). Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As Long ' libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi) ' Get the current movie time (in ms). Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long ' libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi) ' Get current movie state. Private Extern libvlc_media_player_get_state(p_mi As Pointer) As Integer ' void libvlc_media_player_pause (libvlc_media_player_t *p_mi) ' Toggle pause. Private Extern libvlc_media_player_pause(p_mi As Pointer) ' void libvlc_media_player_release (libvlc_media_player_t * p_mi) ' Release a media_player after use Decrement the reference count of a media player object. Private Extern libvlc_media_player_release(p_mi As Pointer) ' void libvlc_media_release (libvlc_media_t *p_md) ' Decrement the reference count of a media descriptor object. Private Extern libvlc_media_release(p_md As Pointer) ' libvlc_release (libvlc_instance_t * p_instance) ' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero. Private Extern libvlc_release(p_instance As Pointer) Public Sub Button1_Click() Dim m As Pointer ' Inizializza la libreria VLC: inst = libvlc_new(0, Null) ' Crea un nuovo oggetto multimedia: m = libvlc_media_new_path(inst, "/percorso/del/file/audio") ' Crea un media player: mp = libvlc_media_player_new_from_media(m) ' Chiude il descrittore dell'oggetto media: libvlc_media_release(m) ' Avvia l'esecuzione del file audio da parte del media player: libvlc_media_player_play(mp) Repeat TextLabel1.Text = "Durata: " & Str(Time(0, 0, 0, libvlc_media_player_get_length(mp, 0))) TextLabel2.Text = "<FONT Color=red>" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) Wait 0.01 Until libvlc_media_player_get_state(mp) > libvlc_Paused ' Rilascia e chiude il media player: libvlc_media_player_release(mp) ' Chiude la libreria VLC: libvlc_release(inst) End Public Sub Button2_Click() ' Arresta l'esecuzione del file audio: libvlc_media_player_stop(mp) End Public Sub ToggleButton1_Click() ' Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio: libvlc_media_player_pause(mp) End
In quest'altro esempio mostreremo un effetto video (Spectrum analyzer) di VLC, che rappresenta un "Analizzatore di spettro", all'interno di una DrawingArea
Private inst As Pointer Private mp As Pointer Library "libvlc:5.6.1" Private Enum libvlc_NothingSpecial = 0, libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, libvlc_Stopped, libvlc_Ended, libvlc_Error ' libvlc_instance_t * libvlc_new (int argc, const char *const *argv) ' Create And initialize a libvlc instance. Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer ' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path) ' Create a media for a certain file path. Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer ' libvlc_media_player_t * libvlc_media_player_new_from_media (libvlc_media_t *p_md) ' Create a Media Player object from a Media. Private Extern libvlc_media_player_new_from_media(p_md As Pointer) As Pointer ' void libvlc_media_player_set_xwindow (libvlc_media_player_t *p_mi, uint32_t drawable) ' Set an X Window System drawable where the media player should render its video output. Private Extern libvlc_media_player_set_xwindow(p_mi As Pointer, drawable As Integer) ' int libvlc_media_player_play (libvlc_media_player_t * p_mi) ' Play the audio file. Private Extern libvlc_media_player_play(p_mi As Pointer) As Integer ' void libvlc_media_player_stop (libvlc_media_player_t * p_mi) ' Stop the audio file. Private Extern libvlc_media_player_stop(p_mi As Pointer) ' libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *) ' Get the current movie length (in ms). Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As Long ' libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi) ' Get the current movie time (in ms). Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long ' libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi) ' Get current movie state. Private Extern libvlc_media_player_get_state(p_mi As Pointer) As Integer ' void libvlc_media_player_pause (libvlc_media_player_t *p_mi) ' Toggle pause. Private Extern libvlc_media_player_pause(p_mi As Pointer) ' void libvlc_media_player_release (libvlc_media_player_t * p_mi) ' Release a media_player after use Decrement the reference count of a media player object. Private Extern libvlc_media_player_release(p_mi As Pointer) ' void libvlc_media_release (libvlc_media_t *p_md) ' Decrement the reference count of a media descriptor object. Private Extern libvlc_media_release(p_md As Pointer) ' libvlc_release (libvlc_instance_t * p_instance) ' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero. Private Extern libvlc_release(p_instance As Pointer) Public Sub Button1_Click() Dim ss As String[] Dim m As Pointer Dim id As Integer ss = ["--audio-visual=visual", "--effect-list=spectrum"] ' Inizializza la libreria VLC: inst = libvlc_new(ss.Count, ss) ' Crea un nuovo oggetto multimedia: m = libvlc_media_new_path(inst, "/percorso/del/file/audio") ' Crea un media player: mp = libvlc_media_player_new_from_media(m) ' Chiude il descrittore dell'oggetto media: libvlc_media_release(m) ' Per far mostrare l'effetto video "Analizzatore di spettro" nella "DrawingArea", ricaviamo il suo identificativo: id = DrawingArea1.Id ' Passiamo l'identificativo della finestra, nella quale dovrà essere mostrato l'effetto "Spectrum analyzer": libvlc_media_player_set_xwindow(mp, id) ' Avvia l'esecuzione del file audio da parte del media player: libvlc_media_player_play(mp) Repeat TextLabel1.Text = "Durata: " & Str(Time(0, 0, 0, libvlc_media_player_get_length(mp, 0))) TextLabel2.Text = "<FONT Color=red>" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) Wait 0.01 Until libvlc_media_player_get_state(mp) > libvlc_Paused ' Rilascia e chiude il media player: libvlc_media_player_release(mp) ' Chiude la libreria VLC: libvlc_release(inst) End Public Sub Button2_Click() ' Arresta l'esecuzione del file audio: libvlc_media_player_stop(mp) End Public Sub ToggleButton1_Click() ' Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio: libvlc_media_player_pause(mp) End
Quest'altro esempio è più completo e complesso del precedente. La particolarità del codice seguente è che è possibile selezionare nel codice fino a 5 effetti grafici VLC.
Private bt1 As Button Private bt2 As Button Private tb As ToggleButton Private tl0 As TextLabel Private tl1 As TextLabel Private tl2 As TextLabel Private menu As Menu Private fileaudio As String Private inst As Pointer Private m As Pointer Private mp As Pointer Library "libvlc:5.6.1" Private Enum libvlc_NothingSpecial = 0, libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, libvlc_Stopped, libvlc_Ended, libvlc_Error ' libvlc_instance_t * libvlc_new (int argc, const char *const *argv) ' Create And initialize a libvlc instance. Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer ' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path) ' Create a media for a certain file path. Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer ' libvlc_media_player_t * libvlc_media_player_new_from_media (libvlc_media_t *p_md) ' Create a Media Player object from a Media. Private Extern libvlc_media_player_new_from_media(p_md As Pointer) As Pointer ' void libvlc_media_player_set_xwindow (libvlc_media_player_t *p_mi, uint32_t drawable) ' Set an X Window System drawable where the media player should render its video output. Private Extern libvlc_media_player_set_xwindow(p_mi As Pointer, drawable As Integer) ' int libvlc_media_player_play (libvlc_media_player_t * p_mi) ' Play the video file. Private Extern libvlc_media_player_play(p_mi As Pointer) As Integer ' void libvlc_media_player_stop (libvlc_media_player_t * p_mi) ' Stop the video file. Private Extern libvlc_media_player_stop(p_mi As Pointer) ' libvlc_time_t libvlc_media_player_get_length(libvlc_media_player_t *, libvlc_exception_t *) ' Get the current movie length (in ms). Private Extern libvlc_media_player_get_length(p_mi As Pointer, l_ex As Pointer) As Long ' libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi) ' Get the current movie time (in ms). Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long ' libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi) ' Get current movie state. Private Extern libvlc_media_player_get_state(p_mi As Pointer) As Integer ' void libvlc_media_player_pause (libvlc_media_player_t *p_mi) ' Toggle pause. Private Extern libvlc_media_player_pause(p_mi As Pointer) ' void libvlc_media_player_release (libvlc_media_player_t * p_mi) ' Release a media_player after use Decrement the reference count of a media player object. Private Extern libvlc_media_player_release(p_mi As Pointer) ' void libvlc_media_release (libvlc_media_t *p_md) ' Decrement the reference count of a media descriptor object. Private Extern libvlc_media_release(p_md As Pointer) ' libvlc_release (libvlc_instance_t * p_instance) ' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero. Private Extern libvlc_release(p_instance As Pointer) Public Sub Form_Open() Dim effetti, ss As String[] Dim argc As Integer GestioneOggetti() effetti = ["dummy", "scope", "spectrum", "spectrometer", "vuMeter"] ss = ["--audio", "--audio-visual=visual", "--effect-list=" & effetti[4], "--visual-80-bands", "--visual-peaks", "--width= 350", "--height=250", "--gain=1.000", "--no-xli"] ' Indica quanti, e dunque, quali effetti, compresi nel vettore "ss" si vogliono utilizzare: argc = ss.Count ' Inizializza la libreria VLC: inst = libvlc_new(argc, ss) End Public Sub Button1_Click() Dim id As Integer Dim DrAr As DrawingArea With DrAr = New DrawingArea(Me) .X = 10 .Y = 10 .W = 350 .H = 250 End With bt1.Enabled = False tb.Enabled = True tb.Value = False ' Crea un nuovo oggetto multimedia. ' Nel secondo argomento della funzione va specificato il percorso del file audio. m = libvlc_media_new_path(inst, fileaudio) ' Crea un media player: mp = libvlc_media_player_new_from_media(m) ' Chiude l'oggetto media: libvlc_media_release(m) ' Per far mostrare l'effetto VLC nella "DrawingArea", ricaviamo il suo identificativo: id = DrAr.Id ' Passiamo l'identificativo della finestra, nella quale dovrà essere mostrato l'effetto VLC: libvlc_media_player_set_xwindow(mp, id) ' Avvia l'esecuzione del file audio da parte del media player: libvlc_media_player_play(mp) Repeat tl1.Text = "Durata: " & Str(Time(0, 0, 0, libvlc_media_player_get_length(mp, 0))) tl2.Text = "<FONT Color=red>" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) Wait 0.01 Until libvlc_media_player_get_state(mp) > libvlc_Paused mp = 0 bt1.Enabled = True End Public Sub Button2_Click() Stop() End Public Sub ToggleButton1_Click() ' Pone in pausa o riprende (se già in pausa) l'esecuzione del file audio: libvlc_media_player_pause(mp) End Public Sub Form_Close() If Object.IsValid(Me) Then Chiude() End Public Sub Menu_Click() Select Case Last.Name Case "Apri" With Dialog .Title = "Apre file..." .Filter = ["*.mp3; *.ogg; *.wav; *.wma", "File audio"] If .OpenFile() Then Return fileaudio = .Path End With If mp > 0 Then Stop() tl0.Text = File.Name(fileaudio) tl1.Text = Null tl2.Text = Null bt1.Enabled = True Case "Esci" Chiude() End Select End Private Procedure Chiude() If mp > 0 Then ' Arresta l'esecuzione del file audio: libvlc_media_player_stop(mp) ' Rilascia e chiude il media player: libvlc_media_player_release(mp) Endif ' Chiude la libreria VLC: libvlc_release(inst) If Object.IsValid(Me) Then Object.Lock(Me) Me.Close Endif End Private Procedure Stop() If mp > 0 Then ' Arresta l'esecuzione del file video: libvlc_media_player_stop(mp) ' Rilascia e chiude il media player: libvlc_media_player_release(mp) Endif tb.Enabled = False tb.Value = False End Private Procedure GestioneOggetti() Dim mn1, mn2 As Menu With Me .W = 400 .H = 370 End With With tl0 = New TextLabel(Me) .X = 10 .Y = 265 .W = 350 .H = 20 End With With tl1 = New TextLabel(Me) .X = 10 .Y = tl0.Y + tl0.H .W = 120 .H = 18 .Alignment = Align.Top End With With tl2 = New TextLabel(Me) .X = tl1.X + tl1.W + 30 .Y = tl0.Y + tl0.H .W = 120 .H = 18 .Alignment = Align.TopLeft End With With bt1 = New Button(Me) As "Button1" .X = 10 .Y = 300 .W = 300 .H = 40 .Foreground = Color.DarkGreen .Text = "Esegui" .Enabled = False End With With bt2 = New Button(Me) As "Button2" .X = bt1.X + bt1.W + 20 .Y = 300 .W = 50 .H = 40 .Foreground = Color.DarkRed .Text = "Stop" End With With tb = New ToggleButton(Me) As "ToggleButton1" .X = bt2.X .Y = 220 .W = 50 .H = 40 .Text = "Pausa" .Enabled = False End With With menu = New Menu(Me) As "Menu" .Caption = "File" End With With mn1 = New Menu(menu, False) As "Menu" .Caption = "Apri file..." .Name = "Apri" End With With mn2 = New Menu(menu, False) As "Menu" .Caption = "Esci" .Name = "Esci" End With End
Esempio con applicazione a riga di comando
Library "libvlc:5.6.1" Private Enum libvlc_NothingSpecial = 0, libvlc_Opening, libvlc_Buffering, libvlc_Playing, libvlc_Paused, libvlc_Stopped, libvlc_Ended, libvlc_Error ' libvlc_instance_t * libvlc_new (int argc, const char *const *argv) ' Create And initialize a libvlc instance. Private Extern libvlc_new(argc As Integer, argv As String[]) As Pointer ' libvlc_media_t * libvlc_media_new_path (libvlc_instance_t *p_instance, const char *path) ' Create a media for a certain file path. Private Extern libvlc_media_new_path(p_instance As Pointer, path As String) As Pointer ' libvlc_media_player_t * libvlc_media_player_new_from_media (libvlc_media_t *p_md) ' Create a Media Player object from a Media. Private Extern libvlc_media_player_new_from_media(p_md As Pointer) As Pointer ' int libvlc_media_player_play (libvlc_media_player_t * p_mi) ' Play the audio file. Private Extern libvlc_media_player_play(p_mi As Pointer) As Integer ' libvlc_time_t libvlc_media_player_get_time(libvlc_media_player_t * p_mi) ' Get the current movie time (in ms). Private Extern libvlc_media_player_get_time(p_mi As Pointer) As Long ' libvlc_state_t libvlc_media_player_get_state(libvlc_media_player_t *p_mi) ' Get current movie state. Private Extern libvlc_media_player_get_state(p_mi As Pointer) As Long ' void libvlc_media_player_release (libvlc_media_player_t * p_mi) ' Release a media_player after use Decrement the reference count of a media player object. Private Extern libvlc_media_player_release(p_mi As Pointer) ' void libvlc_media_release (libvlc_media_t *p_md) ' Decrement the reference count of a media descriptor object. Private Extern libvlc_media_release(p_md As Pointer) ' libvlc_release (libvlc_instance_t * p_instance) ' Decrement the reference count of a libvlc instance, and destroy it if it reaches zero. Private Extern libvlc_release(p_instance As Pointer) Public Sub Main() Dim inst, m, mp As Pointer ' Inizializza la libreria VLC: inst = libvlc_new(0, Null) ' Crea un nuovo oggetto multimedia: m = libvlc_media_new_path(inst, "/percorso/del/file/audio") ' Crea un media player: mp = libvlc_media_player_new_from_media(m) libvlc_media_release(m) ' Avvia l'esecuzione del file audio da parte del media player: libvlc_media_player_play(mp) While libvlc_media_player_get_state(mp) < libvlc_Stopped Write "\r" & Str(Time(0, 0, 0, libvlc_media_player_get_time(mp))) Flush White 0.01 Wend ' Va in chiusura: libvlc_media_player_release(mp) libvlc_release(inst) End