Commit 4249cf6b authored by Martin Finkel's avatar Martin Finkel

Fix MediaPlayer.Play() return

parent 042cee11
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);
}
}
}
......@@ -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).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment