J'essaye de faire marcher un prog trouvé ici
Mais impossible....
J'ai d'abord commencé par remplacer les files$ envoyés en paramètre par des @Files$ (apparement ces fonctions prennent désormais un pointeur en paramètre)
Ensuite il n'arrivait pas à me trouver la libvlccore.dll
Alors dans les options du compilateur -> compiler / executer -> Répertoire courant : j'ai mis le répertoire de vlc (pas génial comme solution, si vous avez mieux dites le moi)
Maintenant ca compil, mais quand je lance le prog il me dit "Accès mémoire invalide" sur cette ligne :
Code : Tout sélectionner
*inst = CallFunction(0, "libvlc_new", 4, @vlc_args(), @ex)
Voici le code :
Code : Tout sélectionner
Global *base = OpenLibrary(0, "C:\Program Files\VideoLAN\VLC\libvlc.dll")
Global file$
OpenWindow(1, 0, 0, 60, 20, "PureBasic VLC dll", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#WS_CLIPCHILDREN|#PB_Window_SizeGadget| #PB_Window_Maximize )
ScrollBarGadget(0, 40, 0, 0, 20, 0, 1000, 1)
ButtonGadget(1, 0, 0, 20, 20, "F") ; file
ButtonGadget(2, 20, 0, 20, 20, ">") ; play
SetGadgetText(2, "||")
OpenWindow(0, 0, 0, 60, 0, "", #PB_Window_BorderLess)
SetWindowColor(0, RGB(0,0,0))
SetParent_(WindowID(0), WindowID(1))
Global ex.l
If *base
Dim vlc_args.s(8)
vlc_args(0) = "-I"
vlc_args(1) = "dummy"
vlc_args(2) = "--ignore-config"
vlc_args(3) = "--plugin-path=C:\\Program Files\\VideoLAN\\VLC\\plugins\\"
CallFunction(0, "libvlc_exception_init", @ex)
*inst = CallFunction(0, "libvlc_new", 4, @vlc_args(), @ex)
; 0.8.6 method
If Len(file$)=0
file$ = OpenFileRequester("Select media file", "", "*.*", 0)
If Len(file$)=0
End
EndIf
EndIf
item = CallFunction(0, "libvlc_playlist_add", *inst, @file$, #Null, @ex)
CallFunction(0, "libvlc_playlist_play", *inst, item, 0, #Null, @ex)
drawable = WindowID(0)
CallFunction(0, "libvlc_video_set_parent", *inst, drawable, @ex)
While wevent<>#PB_Event_CloseWindow
wevent = WindowEvent()
If EventWindow()=0
SetActiveWindow(1)
EndIf
If wevent = #PB_Event_Gadget
Select EventGadget()
Case 0 ; slider
procent.l = GetGadgetState(0)
CallFunction(0, "libvlc_media_player_set_time", *mp, stukje.q*procent, @ex)
Case 1 ; file
file$ = OpenFileRequester("Select media file", "", "*.*", 0)
If Len(file$)
CallFunction(0, "libvlc_playlist_stop", *inst, @ex)
CallFunction(0, "libvlc_playlist_clear", *inst, @ex)
item = CallFunction(0, "libvlc_playlist_add", *inst, @file$, #Null, @ex)
CallFunction(0, "libvlc_playlist_play", *inst, item, 0, #Null, @ex)
Delay(100)
EndIf
Case 2 ; play / pause
If GetGadgetText(2) = ">"
CallFunction(0, "libvlc_media_player_play", *mp, @ex)
SetGadgetText(2, "||")
Else
CallFunction(0, "libvlc_media_player_pause", *mp, @ex)
SetGadgetText(2, ">")
EndIf
EndSelect
EndIf
If wevent=#PB_Event_SizeWindow
If IsGadget(0)
ResizeGadget(0, 40, WindowHeight(1)-20, WindowWidth(1)-40, 20)
EndIf
If IsGadget(1)
ResizeGadget(1, 0, WindowHeight(1)-20, 20, 20)
EndIf
If IsGadget(2)
ResizeGadget(2, 20, WindowHeight(1)-20, 20, 20)
EndIf
ResizeWindow(0, 0, 0, WindowWidth(1), WindowHeight(1)-20)
EndIf
Delay(10)
*mp = CallFunction(0, "libvlc_playlist_get_media_player", *inst, @ex)
state = CallFunction(0, "libvlc_media_player_get_state", *mp, @ex)
Select state
Case 0 ; libvlc_NothingSpecial
Case 1 ; libvlc_Opening
Case 2 ; libvlc_Buffering
Case 3 ; libvlc_Playing
osizex = CallFunction(0, "libvlc_video_get_width", *mp, @ex)
osizey = CallFunction(0, "libvlc_video_get_height", *mp, @ex)
If sizex<>osizex And sizey<>osizey
sizex=osizex
sizey=osizey
ResizeWindow(0, #PB_Ignore, #PB_Ignore, sizex, sizey)
ResizeWindow(1, #PB_Ignore, #PB_Ignore, sizex, sizey+20)
length.q = CallFunction(0, "libvlc_media_player_get_length", *mp, @ex)
stukje.q = length.q / 1000
If length=0
DisableGadget(0, 1)
Else
DisableGadget(0, 0)
EndIf
SetGadgetText(2, "||")
EndIf
curpos.q = CallFunction(0, "libvlc_media_player_get_time", *mp, @ex)
If curpos.q<>curposo.q
curposo.q = curpos.q
stukje.q = length.q / 1000
If stukje>0 And curpos>0
percentage.l = curpos/stukje
SetGadgetState(0, percentage)
EndIf
EndIf
Case 4 ; libvlc_Paused
Case 5 ; libvlc_Stopped
DisableGadget(2, 0)
Case 6 ; libvlc_Forward
Case 7 ; libvlc_Backward
Case 8 ; libvlc_Ended
Case 9 ; libvlc_Error
EndSelect
Wend
If *mp
CallFunction(0, "libvlc_media_player_stop", *mp, @ex)
CallFunction(0, "libvlc_media_player_release", *mp)
EndIf
CallFunction(0, "libvlc_release", *inst)
CloseLibrary(0)
EndIf
CloseLibrary(0)
End
PS : J'ai même rajouté le répertoire de vlc dans la variable d'environnement "Path"