First test of libVLC include files.
-
- Posts: 59
- Joined: Jul 15, 2009 12:41
Re: First test of libVLC include files.
Can someone expand this sample to play the video in a WINDOW created with CreateWindowEx() and a message loop. Thanks in advanced.
Re: First test of libVLC include files.
geminis4941 wrote:Can someone expand this sample to play the video in a WINDOW created with CreateWindowEx() and a message loop. Thanks in advanced.
Small example window.bi + vlc.bi (window version, without image buffer and etc.)
Code: Select all
#Include Once "vlc\vlc.bi"
#Include Once "windows.bi"
Dim msg As MSG
Dim As WNDCLASSEX wc
Dim As String NameClass="MyClass"
Dim As HINSTANCE Hinst=GetModuleHandle(0)
Declare Function wndproc(hwnd As HWND, msg As UInteger,wparam As WPARAM, lparam As LPARAM) As Integer
With wc
.cbSize=SizeOf(WNDCLASSEX)
.style=CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc=@wndproc
.hInstance=Hinst
.hIcon=LoadIcon(0,IDI_QUESTION)
.hCursor=LoadCursor(0,IDC_HELP)
.hbrBackground=Cast(HBRUSH,COLOR_WINDOWFRAME)
.lpszClassName=StrPtr(NameClass)
.hIconSm=.hIcon
End With
If RegisterClassEx(@wc)=0 Then
? "Register error, press any key"
Sleep
End
EndIf
CreateWindowEx(0,NameClass,"Window 1",_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW,100,100,300,300,0,0,Hinst,0)
While GetMessage(@msg,0,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend
Function wndproc(hwnd As HWND, msg As UInteger,_
wparam As WPARAM, lparam As LPARAM) As Integer
Select Case msg
Case WM_DESTROY
PostQuitMessage(0)
Case WM_CREATE '' create pleer after create parent window
Dim As String sPath
sPath = "C:\1.mp4" '' video file path (utf-8?)
Dim p_li As libvlc_instance_t Ptr
Dim p_mi As libvlc_media_player_t Ptr
Dim p_md As libvlc_media_t Ptr
Dim As ZString Ptr vlc_argv(0 To ...) = {@"--no-video-title-show"} '' command line vlc
p_li = libvlc_new(UBound(vlc_argv)+1, @vlc_argv(0))
p_md = libvlc_media_new_path(p_li,sPath)
p_mi = libvlc_media_player_new_from_media( p_md )
libvlc_media_release(p_md)
libvlc_media_player_play( p_mi)
libvlc_media_player_set_hwnd(p_mi, hwnd) '' set parent window
End Select
Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function
(libvlc.dll, libvlccore.dll, plugins folder from \VideoLAN\VLC -> sample folder)
-
- Posts: 433
- Joined: May 05, 2015 5:35
- Location: Germany
Re: First test of libVLC include files.
Alternatively, you can create the VLC instance outside of wndproc and then link it to the window. And maybe additionally you'll have to set a path to libvlc's plugin directory:
Code: Select all
#Include Once "vlc\vlc.bi"
#Include Once "windows.bi"
Dim msg As MSG
Dim As WNDCLASSEX wc
Dim As String NameClass="MyClass"
Dim As HINSTANCE Hinst=GetModuleHandle(0)
Declare Function wndproc(hwnd As HWND, msg As UInteger,wparam As WPARAM, lparam As LPARAM) As Integer
SetEnviron ("VLC_PLUGIN_PATH=e:\vlc-2_2_1\plugins") 'replace with your plugin path
With wc
.cbSize=SizeOf(WNDCLASSEX)
.style=CS_HREDRAW Or CS_VREDRAW
.lpfnWndProc=@wndproc
.hInstance=Hinst
.hIcon=LoadIcon(0,IDI_QUESTION)
.hCursor=LoadCursor(0,IDC_HELP)
.hbrBackground=Cast(HBRUSH,COLOR_WINDOWFRAME)
.lpszClassName=StrPtr(NameClass)
.hIconSm=.hIcon
End With
If RegisterClassEx(@wc)=0 Then
? "Register error, press any key"
Sleep
End
EndIf
CreateWindowEx(0,NameClass,"Window 1",_
WS_VISIBLE Or WS_OVERLAPPEDWINDOW,100,100,300,300,0,0,Hinst,0)
Dim As HWND hwnd = FindWindow(0, "Window 1") 'get window handle
Dim As String sPath
sPath = "C:\1.mp4" '' video file path (utf-8?)
Dim p_li As libvlc_instance_t Ptr
Dim p_mi As libvlc_media_player_t Ptr
Dim p_md As libvlc_media_t Ptr
Dim As ZString Ptr vlc_argv(0 To ...) = {@"--no-video-title-show"} '' command line vlc
p_li = libvlc_new(UBound(vlc_argv)+1, @vlc_argv(0))
p_md = libvlc_media_new_path(p_li,sPath)
p_mi = libvlc_media_player_new_from_media( p_md )
libvlc_media_release(p_md)
libvlc_media_player_play( p_mi)
libvlc_media_player_set_hwnd(p_mi, hwnd) '' set parent window
While GetMessage(@msg,0,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend
Function wndproc(hwnd As HWND, msg As UInteger,_
wparam As WPARAM, lparam As LPARAM) As Integer
Select Case msg
Case WM_DESTROY
PostQuitMessage(0)
End Select
Return DefWindowProc(hwnd,msg,wparam,lparam)
End Function
Who is online
Users browsing this forum: badidea and 5 guests