From 5427d08dd73169cacb735fa0d2e3d82b06aeb315 Mon Sep 17 00:00:00 2001 From: watsonb8 Date: Wed, 22 May 2019 18:59:15 -0400 Subject: [PATCH] Playing works when ran with mono debug --- Aurora.gtk/Aurora.gtk.csproj | 46 +++++++++++++++-- Aurora.gtk/LibVLCSharp.GTK.dll.config | 26 ++++++++++ Aurora.gtk/LibVLCSharp.dll.config | 26 ++++++++++ Aurora.gtk/OpenTK.dll.config | 51 ++++++++++--------- Aurora.gtk/Program.cs | 8 ++- Aurora.gtk/gtk-gui/gui.stetic | 4 ++ Aurora.gtk/packages.config | 11 +++- Aurora/Aurora.csproj | 4 +- Aurora/Backend/Services/LibraryService.cs | 1 - Aurora/Backend/Services/PlayerService.cs | 34 +++++++++++++ Aurora/Frontend/Views/Songs/SongsViewModel.cs | 6 ++- 11 files changed, 181 insertions(+), 36 deletions(-) create mode 100644 Aurora.gtk/LibVLCSharp.GTK.dll.config create mode 100644 Aurora.gtk/LibVLCSharp.dll.config create mode 100644 Aurora/Backend/Services/PlayerService.cs diff --git a/Aurora.gtk/Aurora.gtk.csproj b/Aurora.gtk/Aurora.gtk.csproj index 17c6f46..5716ed4 100644 --- a/Aurora.gtk/Aurora.gtk.csproj +++ b/Aurora.gtk/Aurora.gtk.csproj @@ -81,15 +81,52 @@ ..\packages\Xamarin.Forms.DataGrid.3.1.0\lib\netstandard2.0\Xamarin.Forms.DataGrid.dll - - ..\packages\NAudio.1.9.0\lib\net35\NAudio.dll - + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + ..\packages\LibVLCSharp.3.0.0\lib\net40\LibVLCSharp.dll + + + ..\packages\LibVLCSharp.Forms.3.0.0\lib\netstandard2.0\LibVLCSharp.Forms.dll + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + + + ..\packages\LibVLCSharp.GTK.3.0.0\lib\net47\LibVLCSharp.GTK.dll + + + ..\packages\LibVLCSharp.Forms.GTK.3.0.0\lib\net47\LibVLCSharp.Forms.Platforms.GTK.dll + gui.stetic + + Always + + + Always + + + Always + + + Always + @@ -100,8 +137,6 @@ - - @@ -424,4 +459,5 @@ + \ No newline at end of file diff --git a/Aurora.gtk/LibVLCSharp.GTK.dll.config b/Aurora.gtk/LibVLCSharp.GTK.dll.config new file mode 100644 index 0000000..10de482 --- /dev/null +++ b/Aurora.gtk/LibVLCSharp.GTK.dll.config @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Aurora.gtk/LibVLCSharp.dll.config b/Aurora.gtk/LibVLCSharp.dll.config new file mode 100644 index 0000000..10de482 --- /dev/null +++ b/Aurora.gtk/LibVLCSharp.dll.config @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Aurora.gtk/OpenTK.dll.config b/Aurora.gtk/OpenTK.dll.config index 5620e3d..716277d 100644 --- a/Aurora.gtk/OpenTK.dll.config +++ b/Aurora.gtk/OpenTK.dll.config @@ -1,25 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Aurora.gtk/Program.cs b/Aurora.gtk/Program.cs index a80728d..129fae7 100644 --- a/Aurora.gtk/Program.cs +++ b/Aurora.gtk/Program.cs @@ -1,4 +1,5 @@ using System; +using LibVLCSharp.Forms.Shared; using Xamarin.Forms; using Xamarin.Forms.Platform.GTK; using Xamarin.Forms.Platform.GTK.Helpers; @@ -11,7 +12,12 @@ namespace Aurora.gtk public static void Main(string[] args) { Gtk.Application.Init(); - Forms.Init(); + LibVLCSharpFormsRenderer.Init(); + + // For some reason, Xamarin does not pick the LibVLCSharp.Form.Platforms.Gtk assembly as a renderer assembly. + // Add it manually. + global::Xamarin.Forms.Forms.Init(new[] { typeof(LibVLCSharp.Forms.Platforms.GTK.VideoViewRenderer).Assembly }); + if (PlatformHelper.GetGTKPlatform() == GTKPlatform.Windows) { diff --git a/Aurora.gtk/gtk-gui/gui.stetic b/Aurora.gtk/gtk-gui/gui.stetic index ba25d03..7614896 100644 --- a/Aurora.gtk/gtk-gui/gui.stetic +++ b/Aurora.gtk/gtk-gui/gui.stetic @@ -1,8 +1,12 @@  + + .. + + diff --git a/Aurora.gtk/packages.config b/Aurora.gtk/packages.config index 99db055..1d268c1 100644 --- a/Aurora.gtk/packages.config +++ b/Aurora.gtk/packages.config @@ -1,10 +1,19 @@  - + + + + + + + + + + diff --git a/Aurora/Aurora.csproj b/Aurora/Aurora.csproj index 51e70d9..ad3b7f1 100644 --- a/Aurora/Aurora.csproj +++ b/Aurora/Aurora.csproj @@ -15,7 +15,8 @@ - + + @@ -33,7 +34,6 @@ - diff --git a/Aurora/Backend/Services/LibraryService.cs b/Aurora/Backend/Services/LibraryService.cs index 6e2ad99..1d56f67 100644 --- a/Aurora/Backend/Services/LibraryService.cs +++ b/Aurora/Backend/Services/LibraryService.cs @@ -4,7 +4,6 @@ using System.Collections.ObjectModel; using System.IO; using Aurora.Backend.Models; using Aurora.Backend.Utils; -using NAudio.Wave; namespace Aurora.Backend.Services { diff --git a/Aurora/Backend/Services/PlayerService.cs b/Aurora/Backend/Services/PlayerService.cs new file mode 100644 index 0000000..e9d0624 --- /dev/null +++ b/Aurora/Backend/Services/PlayerService.cs @@ -0,0 +1,34 @@ +using System; +using Aurora.Backend.Models; +using LibVLCSharp.Shared; + +namespace Aurora.Backend.Services +{ + public class PlayerService : BaseService + { + public PlayerService() + { + } + + public void Play(BaseSong song) + { + Core.Initialize(); + using (var libVLC = new LibVLC()) + { + song.Load(); + var media = new Media(libVLC, song.DataStream); + using (var mp = new MediaPlayer(media)) + { + media.Dispose(); + mp.Play(); + Console.ReadKey(); + } + + song.Unload(); + } + + + } + + } +} diff --git a/Aurora/Frontend/Views/Songs/SongsViewModel.cs b/Aurora/Frontend/Views/Songs/SongsViewModel.cs index 18b4506..0105807 100644 --- a/Aurora/Frontend/Views/Songs/SongsViewModel.cs +++ b/Aurora/Frontend/Views/Songs/SongsViewModel.cs @@ -1,7 +1,6 @@ using System.Collections.ObjectModel; using Aurora.Backend.Models; using Aurora.Backend.Services; -using Aurora.Backend.Services.PlayerService; using Xamarin.Forms; namespace Aurora.Frontend.Views.Songs @@ -48,6 +47,11 @@ namespace Aurora.Frontend.Views.Songs SongsList = LibraryService.Instance.GetLibrary(); } + public void PlayExecute() + { + PlayerService.Instance.Play(_selectedSong); + } + #endregion Methods }