Play video with VLC wpf

0

I'm working with VLC to play videos in WPF I get the following error

  

An exception of type occurred   'System.ComponentModel.Win32Exception' on Vlc.DotNet.Core.Interops.dll   but it was not controlled in the user's code Additional information:% 1   it is not a valid Win32 application

The implementation is as follows

XAML

<UserControl x:Name="usrComunicacion" x:Class="GestosCorporales.WpfApplication.View.ComunicacionView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:vlc="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
         xmlns:local="clr-namespace:GestosCorporales.WpfApplication.View"
         mc:Ignorable="d" 
         d:DesignHeight="314.662" Background="White" d:DesignWidth="623.684" Loaded="usrComunicacion_Loaded">

<Grid>
    <StackPanel>
        <TextBlock Text="Comunicación" FontSize="13" Margin="5" HorizontalAlignment="Center"/>
    </StackPanel>

    <DockPanel LastChildFill="True" Margin="20">
        <Grid Margin="15">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="600"/>
            </Grid.RowDefinitions>
            <!--Grid base partido Dos columnas y una fila-->
            <Grid Grid.Row="0">
                <GroupBox Name="gbInteraccion" Header="Interacción" Grid.Row="0" Grid.Column="0">
                    <Label Name="lblStatus"/>
                </GroupBox>
                <Grid Grid.Row="0" Grid.Column="0">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <vlc:VlcControl x:Name="vlcPlayer" Grid.Column="0" Grid.Row="0" Width="280" Height="240" />
                    <Canvas Name="skeletonCanvas" Background="Black" ClipToBounds="True" Margin="0" Grid.Column="1" Grid.Row="0" Width="280" Height="240" />
                    <!--Resultados Videos y Movimientos-->
                    <Grid Grid.Row="1" Grid.Column="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="250"/>
                        </Grid.ColumnDefinitions>
                        <Label Content="Traducción" Grid.Row="0" Grid.Column="0"/>
                        <Label Name="lblTraducion" Grid.Row="0" Grid.Column="1"/>
                    </Grid>
                    <!--Botones-->
                    <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" Margin="10">
                        <Button Name="btnEscuchar" Content="Escuchar" Width="200" Margin="3" Click="btnEscuchar_Click"/>
                        <Button Name="btnCargarMov" Content="Cargar Movimiento" Width="200" Margin="3"/>
                    </StackPanel>
                </Grid>
            </Grid>


            <Grid Grid.Column="1" Grid.Row="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="300"/>
                    <RowDefinition Height="300"/>
                </Grid.RowDefinitions>
                <!--Segunda columna/Dos row-->
                <GroupBox Name="gbVideo" Header="Video" Grid.Row="0">
                    <Image Name="imgVideo" Margin="5" Stretch="Fill"/>
                </GroupBox>

                <GroupBox Name="gb3D"  Header="Profundidad" Grid.Row="1">
                    <Image Name="imgVideo3D" Margin="5" Stretch="Fill"/>
                </GroupBox>
            </Grid>
        </Grid>
    </DockPanel>
</Grid>

C # code

public ComunicacionView()
    {
        InitializeComponent();

        vlcPlayer.MediaPlayer.VlcLibDirectory =
            //replace this path with an appropriate one
            new DirectoryInfo(@"c:\Program Files (x86)\VideoLAN\VLC\");
        vlcPlayer.MediaPlayer.EndInit();//En esta línea me da el error que muestro líneas arriba.
    }

The strange thing is that this implementation had already been done and there were no problems, the implementation was done following this reference.

Integrate VLC player in C # (WPF ) project using Vlc.DotNet

And moving to the real project I get the error that I mention, I'm following all the recommendations.

The test project code is as follows

XAML

<Window x:Class="ReproducirVideoVLC.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vlc="clr-namespace:Vlc.DotNet.Wpf;assembly=Vlc.DotNet.Wpf"
    xmlns:local="clr-namespace:ReproducirVideoVLC"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <vlc:VlcControl x:Name="vlcPlayer"/>

</Grid>

Code C #

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        vlcPlayer.MediaPlayer.VlcLibDirectory =
        //replace this path with an appropriate one
        new DirectoryInfo(@"c:\Program Files (x86)\VideoLAN\VLC\");
        vlcPlayer.MediaPlayer.EndInit();
        vlcPlayer.MediaPlayer.Play(new Uri(@"D:\PruebasCSharp\ReconocimientoVoz\Video\WPF Media Element.wmv"));
    }
}
  

The only difference is that in the real project I use a UserControl and in   the test project use Windows (window).

I have just done more tests in the real project I have placed the same implementation in a Windows (window) and gives the same error.

In the test project I added a usercontrol I made the implementation and it does not give an error.

My computer is a PC with Windows OS 64 64 bits, the weird thing is that in the test implementation that I made, I did not get any errors.

    
asked by Pedro Ávila 18.10.2017 в 18:51
source

1 answer

0

I just solved the problem, I had unchecked in the Buil the box Preferably 32 bits.

    
answered by 19.10.2017 в 22:35