Right then, here is a working example at least on linux using old deprecated functions
haven't gotten around to upgrading it yet, one thing at a time, I first needed to *cough* clean *cough* the code a bit so that I could understand what was going on, hope you can identify your finger prints
Code: Select all
;*****************************************************************************
; Example: pbvlc.pb
; By: T.J.Roughton
; Requires: libvlc.pb (includes)
;*****************************************************************************
IncludeFile "libvlc.pb"
Enumeration
#WINDOW_PLAYMEDIA
EndEnumeration
Enumeration
#GAD_TRACKBAR
#GAD_FILE
#GAD_PLAYPAUSE
#GAD_MEDIACONTAINER
EndEnumeration
Global Dim vlc_args.s(8)
Global Dim utf8args(8)
;*****************************************************************************
; VLC Exception
;*****************************************************************************
Procedure Debug_Exception(cmd.s,ex.l,result.l=-1)
*exception.libvlc_exception=ex
OpenConsole()
PrintN(cmd+" = "+Str(result))
PrintN("libvlc_exception\raised="+Str(*exception\raised))
PrintN("libvlc_exception\code="+Str(*exception\code))
PrintN("libvlc_exception\message="+*exception\message)
CloseConsole()
EndProcedure
;*****************************************************************************
; Choose URL/File
;*****************************************************************************
Procedure.s OpenWindow_ChooseURLFILE()
result.s=""
If OpenWindow(0, 0, 0, 300, 50, "Choose URL/File", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
ButtonGadget(1,10,10,135,30,"URL")
ButtonGadget(2,155,10,135,30,"FILE")
While wevent<>#PB_Event_CloseWindow
wevent = WindowEvent()
If wevent = #PB_Event_Gadget
Select EventGadget()
Case 1 ; URL
result.s=InputRequester("URL","Enter URL","")
wevent=#PB_Event_CloseWindow
Case 2 ; FILE
result.s=OpenFileRequester("File","","",0)
wevent=#PB_Event_CloseWindow
EndSelect
EndIf
Wend
EndIf
CloseWindow(0)
ProcedureReturn result
EndProcedure
;*****************************************************************************
; Set Args
;*****************************************************************************
Procedure SetArguments(location.s)
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"
PBVLC_MakeArgs(vlc_args(), 8, utf8args())
EndProcedure
;*****************************************************************************
; Roll it!
;*****************************************************************************
Procedure OpenWindow_PlayMedia(location.s)
exception.libvlc_exception
If OpenWindow(#WINDOW_PLAYMEDIA, 0, 0, 60, 20, "PureBasic VLC", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
ButtonGadget(#GAD_PLAYPAUSE, 0, 0, 0, 0, "F")
ButtonGadget(#GAD_FILE, 0, 0, 0, 0, ">")
ScrollBarGadget(#GAD_TRACKBAR, 0, 0, 0, 0, 0, 1000, 1)
ContainerGadget(#GAD_MEDIACONTAINER, 0, 0, 0, 0)
drawable=PBVLC_XDisplayFromWindowID(GadgetID(#GAD_MEDIACONTAINER))
; Set the arguments up for VLC
SetArguments(location)
; Init
libvlc_exception_init(@exception)
instants = libvlc_new (8,@utf8args(),@exception)
item = libvlc_playlist_add (instants,@location,#Null,@exception)
libvlc_playlist_play (instants,item,0,#Null,@exception)
mplayer = libvlc_playlist_get_media_player (instants,@exception)
; we must start playing so that libvlc_video_set_parent has some input first!
libvlc_video_set_parent (instants,drawable,@exception)
oldwsize.l=0
oldhsize.l=0
oldcurpos.q=0
While wevent<>#PB_Event_CloseWindow
wevent = WindowEvent()
If wevent = #PB_Event_Gadget
Select EventGadget()
Case #GAD_TRACKBAR
Case #GAD_FILE
Case #GAD_PLAYPAUSE
Case #GAD_MEDIACONTAINER
EndSelect
EndIf
If wevent=#PB_Event_SizeWindow
If IsGadget(#GAD_TRACKBAR)
ResizeGadget(#GAD_TRACKBAR, 40, WindowHeight(#WINDOW_PLAYMEDIA)-20, WindowWidth(#WINDOW_PLAYMEDIA)-40, 20)
EndIf
If IsGadget(#GAD_FILE)
ResizeGadget(#GAD_FILE, 0, WindowHeight(#WINDOW_PLAYMEDIA)-20, 20, 20)
EndIf
If IsGadget(#GAD_PLAYPAUSE)
ResizeGadget(#GAD_PLAYPAUSE, 20, WindowHeight(#WINDOW_PLAYMEDIA)-20, 20, 20)
EndIf
If IsGadget(#GAD_MEDIACONTAINER)
ResizeGadget(#GAD_MEDIACONTAINER, 0, 0, WindowWidth(#WINDOW_PLAYMEDIA), WindowHeight(#WINDOW_PLAYMEDIA)-20)
EndIf
EndIf
state = libvlc_media_player_get_state(mplayer, @exception)
Select state
Case 0 ; libvlc_NothingSpecial
Case 1 ; libvlc_Opening
Case 2 ; libvlc_Buffering
Case 3 ; libvlc_Playing
width=libvlc_video_get_width(mplayer,@exception)
height=libvlc_video_get_height(mplayer,@exception)
curpos.q=libvlc_media_player_get_time(mplayer,@exception)
If (width<>oldwsize And height<>oldhsize)
oldwsize=width
oldhsize=height
ResizeWindow(#WINDOW_PLAYMEDIA,#PB_Ignore,#PB_Ignore,width,height+20)
;
length.q=libvlc_media_player_get_length(mplayer,@exception)
stukje.q=length.q/1000
If length=0
DisableGadget(#GAD_TRACKBAR,1)
Else
DisableGadget(#GAD_TRACKBAR,0)
EndIf
SetGadgetText(#GAD_PLAYPAUSE, "||")
EndIf
If curpos<>oldcurpos
curposo=curpos
stukje.q = length / 1000
If (stukje>0 And curpos>0)
SetGadgetState(#GAD_TRACKBAR,curpos/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
Delay(1)
Wend
If mplayer
libvlc_media_player_stop(mplayer,@exception)
libvlc_media_player_release(mplayer)
EndIf
libvlc_release(instants)
CloseWindow(#WINDOW_PLAYMEDIA)
EndIf
EndProcedure
;-----------------------------------------------------------------------------
OpenWindow_PlayMedia(OpenWindow_ChooseURLFILE())