Commit 116ab67e authored by Martin Finkel's avatar Martin Finkel

wip: reactive sample test

parent 1e2bd22a
......@@ -7,6 +7,7 @@
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Reactive" Version="4.4.1" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.8" />
<PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.3" />
</ItemGroup>
......
using System;
using System.Reactive.Linq;
using LibVLCSharp.Shared;
namespace LibVLCSharp.NetCore.Sample
......@@ -10,6 +11,8 @@ namespace LibVLCSharp.NetCore.Sample
Core.Initialize();
using var libVLC = new LibVLC();
libVLC.OLog.Subscribe(m => Console.WriteLine(m));
using var media = new Media(libVLC, new Uri("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"));
using var mp = new MediaPlayer(media);
mp.Play();
......
......@@ -87,6 +87,10 @@ LibVLC needs to be installed separately, see VideoLAN.LibVLC.* packages.</Descri
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Condition=" '$(TargetFramework)' != 'netstandard1.1' AND '$(TargetFramework)' != 'net40'"
Include="System.Reactive" Version="4.4.1"/>
</ItemGroup>
<Target Name="IncludeAWindow" Condition="$(TargetFramework.StartsWith('MonoAndroid'))">
<ItemGroup>
<BuildOutputInPackage Include="$(OutputPath)LibVLCSharp.Android.AWindow.dll" />
......
using System;
using System.Collections.Generic;
using System.Linq;
#if !NET40 && !NETSTANDARD1_1
using System.Reactive.Linq;
#endif
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
......@@ -229,6 +232,10 @@ namespace LibVLCSharp.Shared
: base(() => MarshalUtils.CreateWithOptions(PatchOptions(options), Native.LibVLCNew), Native.LibVLCRelease)
{
_gcHandle = GCHandle.Alloc(this);
#if !NET40 && !NETSTANDARD1_1
OLog = Observable.FromEventPattern<EventHandler<LogEventArgs>, LogEventArgs>(e => Log += e, e => Log -= e).Select(p => p.EventArgs.FormattedLog);
#endif
}
/// <summary>
......@@ -408,6 +415,12 @@ namespace LibVLCSharp.Shared
return filePtr;
}
#endif
#if !NET40 && !NETSTANDARD1_1
/// <summary>
/// Observable libvlc log event
/// </summary>
public IObservable<string> OLog { get; }
#endif
int _logSubscriberCount = 0;
/// <summary>
......
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