Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Martin Finkel
LibVLCSharp
Commits
34bb2f98
Commit
34bb2f98
authored
Mar 24, 2018
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use LoadLibrary with custom path to libvlc dlls. win32 only
parent
848a00fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
Sample/Program.cs
Sample/Program.cs
+25
-0
No files found.
Sample/Program.cs
View file @
34bb2f98
using
System
;
using
System.IO
;
using
System.Runtime.InteropServices
;
using
VideoLAN.LibVLC
;
using
Media
=
VideoLAN
.
LibVLC
.
Media
;
...
...
@@ -8,11 +11,33 @@ namespace Sample
{
static
void
Main
(
string
[]
args
)
{
var
myPath
=
new
Uri
(
typeof
(
Instance
).
Assembly
.
CodeBase
).
LocalPath
;
var
appExecutionDirectory
=
Path
.
GetDirectoryName
(
myPath
);
if
(
appExecutionDirectory
==
null
)
throw
new
NullReferenceException
(
nameof
(
appExecutionDirectory
));
// TODO: check if running in a Store app
var
arch
=
Environment
.
Is64BitProcess
?
"win-x64"
:
"win-x86"
;
const
string
libvlc
=
"libvlc"
;
const
string
libvlccore
=
"libvlccore"
;
var
libvlccorePath
=
Path
.
Combine
(
Path
.
Combine
(
appExecutionDirectory
,
libvlc
),
Path
.
Combine
(
arch
,
$"
{
libvlccore
}
.dll"
));
var
libvlcPath
=
Path
.
Combine
(
Path
.
Combine
(
appExecutionDirectory
,
libvlc
),
Path
.
Combine
(
arch
,
$"
{
libvlc
}
.dll"
));
var
r1
=
LoadLibrary
(
libvlccorePath
);
var
r2
=
LoadLibrary
(
libvlcPath
);
var
instance
=
new
Instance
();
var
media
=
new
Media
(
instance
,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"
,
Media
.
FromType
.
FromLocation
);
var
mp
=
new
MediaPlayer
(
media
);
mp
.
Play
();
Console
.
ReadKey
();
}
[
DllImport
(
"kernel32.dll"
,
SetLastError
=
true
)]
static
extern
IntPtr
LoadLibrary
(
string
dllToLoad
);
[
DllImport
(
"kernel32.dll"
,
SetLastError
=
true
)]
static
extern
IntPtr
LoadPackagedLibrary
(
string
dllToLoad
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment