After some search i found a solution ..
Code: Select all
Structure prog
*inst
*base
*mp
*m
*state
*item
drawable.l
wevent.l
procent.l
stukje.q
reload.b
sizex.l
sizey.l
osizex.l
osizey.l
length.q
curpos.q
curposo.q
ex.l
file$
i.l
EndStructure
Global Dim vlc_args.s(8)
Global Dim utf8args(8)
Global p.prog
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
SetCurrentDirectory("/usr/lib/")
Global p\base = OpenLibrary(0, "/usr/lib/libvlc.so")
Procedure makeargs(Array Array.s(1), num, Array newarr(1))
p\i = 0
Repeat
newarr(p\i) = AllocateMemory(StringByteLength(Array(p\i))+1)
PokeS(newarr(p\i), Array(p\i), -1, #PB_UTF8)
p\i+1
Until p\i>=num
EndProcedure
Structure _GdkScreen Extends GdkScreen ; PB def seems to be incomplete
*font_options;
resolution.d; /* pixels/points scale factor for fonts */
EndStructure
Structure GdkScreenX11
parent_instance._GdkScreen;
*display;
*xdisplay;
*xscreen;
EndStructure
Structure GdkDrawableImplX11
parent_instance.GdkDrawable
*wrapper;
*colormap;
xid.l
*screen
picture.l ;Picture
*cairo_surface;
EndStructure
Structure _GdkWindowObject ; PB def is empty!
parent_instance.GdkDrawable;
*impl.GdkDrawable ; /* window-system-specific delegate object */
*parent;
user_data.l
EndStructure
Procedure XDisplayFromWindowID(*Window.GtkWidget)
*gdkwindowobj._GdkWindowObject = *Window\window
*impl.GdkDrawableImplX11 = *gdkwindowobj\impl
*screen.GdkScreenX11 = *impl\screen
ProcedureReturn *impl\xid ;*screen\xdisplay
EndProcedure
CompilerCase #PB_OS_Windows
SetCurrentDirectory("C:\Program Files\VideoLAN\VLC")
Global p\base = OpenLibrary(0, "C:\Program Files\VideoLAN\VLC\libvlc.dll")
Procedure makeargs(Array.s(1), num, newarr(1))
p\i = 0
Repeat
newarr(p\i) = AllocateMemory(StringByteLength(Array(p\i))+1)
PokeS(newarr(p\i), Array(p\i), -1, #PB_UTF8)
p\i+1
Until p\i>=num
EndProcedure
CompilerEndSelect
If p\base
OpenWindow(1, 0, 0, 60, 20, "PureBasic VLC", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
ScrollBarGadget(0, 0, 0, 0, 0, 0, 1000, 1)
ButtonGadget(1, 0, 0, 0, 0, "F")
ButtonGadget(2, 0, 0, 0, 0, ">")
SetGadgetText(2, "||")
ContainerGadget(3, 0, 0, 0, 0)
vlc_args(0) = "-I"
vlc_args(1) = "dummy"
vlc_args(2) = "--ignore-config"
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
vlc_args(3) = "--plugin-path=/usr/lib/vlc/codecs/"
CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
vlc_args(3) = "--plugin-path=C:\\Program Files\\VideoLAN\\VLC\\plugins\"
CompilerEndIf
vlc_args(4) = "--mms-caching"
vlc_args(5) = "3200"
vlc_args(6) = "--http-caching"
vlc_args(7) = "3200"
makeargs(vlc_args(), 8, utf8args())
CallFunction(0, "libvlc_exception_init", @p\ex)
p\inst = CallFunction(0, "libvlc_new", 8, @utf8args(), @p\ex) ;vlc_args(), @p\ex)
p\file$ = "mms://85.119.217.29/TMFLive"
;; 0.9+ way
;p\m = CallFunction(0, "libvlc_media_new", p\inst, p\file$, @p\ex)
;p\mp = CallFunction(0, "libvlc_media_player_new_from_media", p\m, @p\ex)
;CallFunction(0, "libvlc_media_release", p\m, @p\ex)
;p\drawable = GadgetID(3)
;CallFunction(0, "libvlc_media_player_set_drawable", p\mp, p\drawable, @p\ex)
;CallFunction(0, "libvlc_media_player_play", p\mp, @p\ex)
;p\reload=1
; 0.9- way
p\item = CallFunction(0, "libvlc_playlist_add", p\inst, p\file$, #Null, @p\ex)
p\drawable = GadgetID(3)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
p\drawable = XDisplayFromWindowID(GadgetID(3))
CompilerEndIf
CallFunction(0, "libvlc_video_set_parent", p\inst, p\drawable, @p\ex)
CallFunction(0, "libvlc_playlist_play", p\inst, p\item, 0, #Null, @p\ex)
While p\wevent<>#PB_Event_CloseWindow
p\wevent = WindowEvent()
If p\wevent = #PB_Event_Gadget
Select EventGadget()
Case 0 ; slider
If p\mp
p\procent.l = GetGadgetState(0)
CallFunction(0, "libvlc_media_player_set_time", p\mp, p\stukje.q*p\procent, @p\ex)
EndIf
Case 1 ; file
p\file$ = OpenFileRequester("Select media file", "", "*.*", 0)
If Len(p\file$)
; v9+
; v9-
CallFunction(0, "libvlc_playlist_stop", p\inst, @p\ex)
CallFunction(0, "libvlc_playlist_clear", p\inst, @p\ex)
p\item = CallFunction(0, "libvlc_playlist_add", p\inst, p\file$, #Null, @p\ex)
CallFunction(0, "libvlc_playlist_play", p\inst, p\item, 0, #Null, @p\ex)
p\reload=0
EndIf
Case 2 ; play / pause
If GetGadgetText(2) = ">"
CallFunction(0, "libvlc_media_player_play", p\mp, @p\ex)
SetGadgetText(2, "||")
Else
CallFunction(0, "libvlc_media_player_pause", p\mp, @p\ex)
SetGadgetText(2, ">")
EndIf
EndSelect
EndIf
If p\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
If IsGadget(3)
ResizeGadget(3, 0, 0, WindowWidth(1), WindowHeight(1)-20)
EndIf
EndIf
Delay(10)
If p\reload=0
p\mp = CallFunction(0, "libvlc_playlist_get_media_player", p\inst, @p\ex)
If p\mp And p\m=0
p\m = CallFunction(0, "libvlc_media_player_get_media", p\mp, @p\ex)
p\reload=1
EndIf
EndIf
p\state = CallFunction(0, "libvlc_media_player_get_state", p\mp, @p\ex)
Select p\state
Case 0 ; libvlc_NothingSpecial
Case 1 ; libvlc_Opening
Case 2 ; libvlc_Buffering
Case 3 ; libvlc_Playing
p\sizex = CallFunction(0, "libvlc_video_get_width", p\mp, @p\ex)
p\sizey = CallFunction(0, "libvlc_video_get_height", p\mp, @p\ex)
If p\sizex<>p\osizex And p\sizey<>p\osizey
p\osizex=p\sizex
p\osizey=p\sizey
ResizeWindow(1, #PB_Ignore, #PB_Ignore, p\sizex, p\sizey+20)
p\length.q = CallFunction(0, "libvlc_media_player_get_length", p\mp, @p\ex)
p\stukje.q = p\length.q / 1000
If p\length=0
DisableGadget(0, 1)
Else
DisableGadget(0, 0)
EndIf
SetGadgetText(2, "||")
EndIf
p\curpos.q = CallFunction(0, "libvlc_media_player_get_time", p\mp, @p\ex)
If p\curpos.q<>p\curposo.q
p\curposo.q = p\curpos.q
p\stukje.q = p\length.q / 1000
If p\stukje>0 And p\curpos>0
SetGadgetState(0, p\curpos/p\stukje)
EndIf
EndIf
Case 4 ; libvlc_Paused
Case 5 ; libvlc_Stopped
Case 6 ; libvlc_Forward
Case 7 ; libvlc_Backward
Case 8 ; libvlc_Ended
Case 9 ; libvlc_Error
EndSelect
Wend
If p\mp
CallFunction(0, "libvlc_media_player_stop", p\mp, @p\ex)
CallFunction(0, "libvlc_media_player_release", p\mp)
EndIf
CallFunction(0, "libvlc_release", p\inst)
CloseLibrary(0)
EndIf
End
Phil.