From c6cace8c7cd71ea9931618bfa4aa9e914ceff901 Mon Sep 17 00:00:00 2001 From: Arti Zirk Date: Wed, 9 Nov 2016 05:16:32 +0200 Subject: [PATCH] Working player --- MainWindow.xaml | 3 ++- MainWindow.xaml.cs | 29 +++++++++++++++++++++++++++++ VideoPlayer.csproj | 41 +++++++++++++++++++++++++++++++++++++++++ VideoPlayer.sln | 6 ++++++ packages.config | 7 +++++++ 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 packages.config diff --git a/MainWindow.xaml b/MainWindow.xaml index 4e83442..456c90d 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -4,9 +4,10 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:VideoPlayer" + xmlns:wpf="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> - + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 3746d5e..1993bb9 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -20,9 +23,35 @@ namespace VideoPlayer /// public partial class MainWindow : Window { + [DllImport("Kernel32")] + public static extern void AllocConsole(); + + [DllImport("Kernel32")] + public static extern void FreeConsole(); + public MainWindow() { + AllocConsole(); + Console.WriteLine("Hello"); + Console.WriteLine("Current dir: {0}", Directory.GetCurrentDirectory()); InitializeComponent(); + myControl.MediaPlayer.VlcLibDirectoryNeeded += OnVlcControlNeedsLibDirectory; + myControl.MediaPlayer.EndInit(); + myControl.MediaPlayer.Play(new Uri("https://u.wut.ee/leekima.webm")); + } + + private void OnVlcControlNeedsLibDirectory(object sender, Vlc.DotNet.Forms.VlcLibDirectoryNeededEventArgs e) + { + var currentAssembly = Assembly.GetEntryAssembly(); + var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName; + if (currentDirectory == null) + return; + Console.WriteLine("fromvlc: currentdir: {0}", currentDirectory); + if (AssemblyName.GetAssemblyName(currentAssembly.Location).ProcessorArchitecture == ProcessorArchitecture.X86) + e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"..\..\..\lib\x86\")); + else + e.VlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, @"..\..\lib\x64\")); + Console.WriteLine(e.VlcLibDirectory); } } } diff --git a/VideoPlayer.csproj b/VideoPlayer.csproj index 029ac0f..4fafe3d 100644 --- a/VideoPlayer.csproj +++ b/VideoPlayer.csproj @@ -34,9 +34,32 @@ prompt 4 + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + + @@ -46,9 +69,26 @@ 4.0 + + packages\Vlc.DotNet.Core.2.1.126\lib\net45\x86\Vlc.DotNet.Core.dll + True + + + packages\Vlc.DotNet.Core.Interops.2.1.126\lib\net45\x86\Vlc.DotNet.Core.Interops.dll + True + + + packages\Vlc.DotNet.Forms.2.1.126\lib\net45\x86\Vlc.DotNet.Forms.dll + True + + + packages\Vlc.DotNet.Wpf.2.1.126\lib\net45\x86\Vlc.DotNet.Wpf.dll + True + + @@ -86,6 +126,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/VideoPlayer.sln b/VideoPlayer.sln index efcde84..68fb282 100644 --- a/VideoPlayer.sln +++ b/VideoPlayer.sln @@ -8,13 +8,19 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9E787551-8030-44F4-B084-B0044945AB65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9E787551-8030-44F4-B084-B0044945AB65}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E787551-8030-44F4-B084-B0044945AB65}.Debug|x86.ActiveCfg = Debug|x86 + {9E787551-8030-44F4-B084-B0044945AB65}.Debug|x86.Build.0 = Debug|x86 {9E787551-8030-44F4-B084-B0044945AB65}.Release|Any CPU.ActiveCfg = Release|Any CPU {9E787551-8030-44F4-B084-B0044945AB65}.Release|Any CPU.Build.0 = Release|Any CPU + {9E787551-8030-44F4-B084-B0044945AB65}.Release|x86.ActiveCfg = Release|x86 + {9E787551-8030-44F4-B084-B0044945AB65}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..7b6590a --- /dev/null +++ b/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file