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
4249cf6b
Commit
4249cf6b
authored
Dec 03, 2017
by
Martin Finkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MediaPlayer.Play() return
parent
042cee11
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
16 deletions
+52
-16
Bindings.Tests/MediaPlayerTests.cs
Bindings.Tests/MediaPlayerTests.cs
+48
-2
libvlcsharp/Manual/MediaPlayer.cs
libvlcsharp/Manual/MediaPlayer.cs
+4
-14
No files found.
Bindings.Tests/MediaPlayerTests.cs
View file @
4249cf6b
using
System
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
NUnit.Framework
;
using
VideoLAN.LibVLC
;
using
VideoLAN.LibVLC.Manual
;
using
MediaPlayer
=
VideoLAN
.
LibVLC
.
Manual
.
MediaPlayer
;
...
...
@@ -17,11 +22,52 @@ namespace Bindings.Tests
}
[
Test
]
public
void
T
()
public
void
OutputDeviceEnum
()
{
var
mp
=
new
MediaPlayer
(
new
Instance
());
var
t
=
mp
.
OutputDeviceEnum
;
Debug
.
WriteLine
(
t
);
}
string
RealMediaPath
{
get
{
var
dir
=
AppDomain
.
CurrentDomain
.
SetupInformation
.
ApplicationBase
;
// var binDir = Path.Combine(dir, "..\\..\\..\\");
var
files
=
Directory
.
GetFiles
(
dir
);
return
files
.
First
();
}
}
[
Test
]
public
void
TrackDescription
()
{
//FIX ME
var
instance
=
new
Instance
();
var
mp
=
new
MediaPlayer
(
instance
);
var
media
=
new
Media
(
instance
,
RealMediaPath
,
Media
.
FromType
.
FromPath
);
mp
.
Media
=
media
;
var
track
=
mp
.
AudioTrack
;
Assert
.
True
(
mp
.
SetAudioTrack
(
track
));
Assert
.
IsNotEmpty
(
mp
.
AudioTrackDescription
);
}
[
Test
]
public
async
Task
Play
()
{
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
);
var
called
=
false
;
mp
.
EventManager
.
Playing
+=
(
sender
,
args
)
=>
{
called
=
true
;
};
mp
.
Play
();
await
Task
.
Delay
(
5000
);
Assert
.
True
(
called
);
Assert
.
True
(
mp
.
IsPlaying
);
}
}
}
libvlcsharp/Manual/MediaPlayer.cs
View file @
4249cf6b
...
...
@@ -641,20 +641,12 @@ namespace VideoLAN.LibVLC.Manual
:
base
(()
=>
Native
.
LibVLCMediaPlayerNewFromMedia
(
media
.
NativeReference
),
Native
.
LibVLCMediaPlayerRelease
)
{
}
/// <summary>
/// Get the media used by the media_player.
/// Set the media that will be used by the media_player.
/// If any, previous md will be released.
/// </summary>
/// <param name="media">the Media. Afterwards the p_md can be safely destroyed</param>
public
void
SetMedia
(
Media
media
)
{
Native
.
LibVLCMediaPlayerSetMedia
(
NativeReference
,
media
.
NativeReference
);
}
/// <summary>
/// Get the media used by the media_player.
/// </summary>
public
Media
Media
{
get
...
...
@@ -662,6 +654,7 @@ namespace VideoLAN.LibVLC.Manual
var
mediaPtr
=
Native
.
LibVLCMediaPlayerGetMedia
(
NativeReference
);
return
mediaPtr
==
IntPtr
.
Zero
?
null
:
new
Media
(
mediaPtr
);
}
set
=>
Native
.
LibVLCMediaPlayerSetMedia
(
NativeReference
,
value
.
NativeReference
);
}
/// <summary>
...
...
@@ -690,10 +683,7 @@ namespace VideoLAN.LibVLC.Manual
/// If playback was already started, this method has no effect
/// </summary>
/// <returns></returns>
public
bool
Play
()
{
return
Native
.
LibVLCMediaPlayerPlay
(
NativeReference
)
!=
0
;
}
public
bool
Play
()
=>
Native
.
LibVLCMediaPlayerPlay
(
NativeReference
)
==
0
;
/// <summary>
/// Pause or resume (no effect if there is no media).
...
...
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