Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
450
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
4a91e760
Commit
4a91e760
authored
4 years ago
by
Steve Lhomme
Browse files
Options
Downloads
Patches
Plain Diff
doc: libvlc: add a simple win32 app using set_hwnd()
parent
985413c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#17081
passed with stage
in 26 minutes and 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/libvlc/win_player.c
+100
-0
100 additions, 0 deletions
doc/libvlc/win_player.c
with
100 additions
and
0 deletions
doc/libvlc/win_player.c
0 → 100644
+
100
−
0
View file @
4a91e760
/* compile: cc win_player.c -o win_player.exe -L<path/libvlc> -lvlc */
#include
<windows.h>
#include
<assert.h>
#include
<vlc/vlc.h>
#define SCREEN_WIDTH 1500
#define SCREEN_HEIGHT 900
static
LRESULT
CALLBACK
WindowProc
(
HWND
hWnd
,
UINT
message
,
WPARAM
wParam
,
LPARAM
lParam
)
{
switch
(
message
)
{
case
WM_DESTROY
:
PostQuitMessage
(
0
);
return
0
;
}
return
DefWindowProc
(
hWnd
,
message
,
wParam
,
lParam
);
}
int
WINAPI
WinMain
(
HINSTANCE
hInstance
,
HINSTANCE
hPrevInstance
,
LPSTR
lpCmdLine
,
int
nCmdShow
)
{
WNDCLASSEX
wc
;
char
*
file_path
;
libvlc_instance_t
*
p_libvlc
;
libvlc_media_t
*
p_media
;
libvlc_media_player_t
*
p_mp
;
(
void
)
hPrevInstance
;
HWND
hWnd
;
/* remove "" around the given path */
if
(
lpCmdLine
[
0
]
==
'"'
)
{
file_path
=
strdup
(
lpCmdLine
+
1
);
if
(
file_path
[
strlen
(
file_path
)
-
1
]
==
'"'
)
file_path
[
strlen
(
file_path
)
-
1
]
=
'\0'
;
}
else
file_path
=
strdup
(
lpCmdLine
);
p_libvlc
=
libvlc_new
(
0
,
NULL
);
p_media
=
libvlc_media_new_path
(
p_libvlc
,
file_path
);
free
(
file_path
);
p_mp
=
libvlc_media_player_new_from_media
(
p_media
);
ZeroMemory
(
&
wc
,
sizeof
(
WNDCLASSEX
));
wc
.
cbSize
=
sizeof
(
WNDCLASSEX
);
wc
.
style
=
CS_HREDRAW
|
CS_VREDRAW
;
wc
.
lpfnWndProc
=
WindowProc
;
wc
.
hInstance
=
hInstance
;
wc
.
hCursor
=
LoadCursor
(
NULL
,
IDC_ARROW
);
wc
.
lpszClassName
=
"WindowClass"
;
RegisterClassEx
(
&
wc
);
RECT
wr
=
{
0
,
0
,
SCREEN_WIDTH
,
SCREEN_HEIGHT
};
AdjustWindowRect
(
&
wr
,
WS_OVERLAPPEDWINDOW
,
FALSE
);
hWnd
=
CreateWindowEx
(
0
,
"WindowClass"
,
"libvlc Demo app"
,
WS_OVERLAPPEDWINDOW
,
CW_USEDEFAULT
,
CW_USEDEFAULT
,
wr
.
right
-
wr
.
left
,
wr
.
bottom
-
wr
.
top
,
NULL
,
NULL
,
hInstance
,
NULL
);
libvlc_media_player_set_hwnd
(
p_mp
,
hWnd
);
ShowWindow
(
hWnd
,
nCmdShow
);
libvlc_media_player_play
(
p_mp
);
MSG
msg
;
while
(
GetMessage
(
&
msg
,
NULL
,
0
,
0
))
{
TranslateMessage
(
&
msg
);
DispatchMessage
(
&
msg
);
if
(
msg
.
message
==
WM_QUIT
)
break
;
}
libvlc_media_player_stop_async
(
p_mp
);
libvlc_media_player_release
(
p_mp
);
libvlc_media_release
(
p_media
);
libvlc_release
(
p_libvlc
);
return
msg
.
wParam
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment