3

Repro code:

<Window x:Class="MediaBox.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MediaBox"
        Title="MainWindow">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <MediaElement LoadedBehavior="Play"
                      MediaFailed="OnMediaFailed"
                      Source="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                      AncestorType={x:Type local:MainWindow}},
                                       Path=FileName}" />
        <Button Grid.Row="1"
                Click="OnOpenClick"
                Content="Open" />
    </Grid>
</Window>
public partial class MainWindow : Window
{
    public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register(
        nameof(FileName),
        typeof(string),
        typeof(MainWindow),
        new PropertyMetadata(default(string)));

    public MainWindow()
    {
        this.InitializeComponent();
    }

    public string FileName
    {
        get { return (string)this.GetValue(FileNameProperty); }
        set { this.SetValue(FileNameProperty, value); }
    }

    private void OnOpenClick(object sender, RoutedEventArgs e)
    {
        var openFileDialog = new OpenFileDialog();
        if (openFileDialog.ShowDialog() == true)
        {
            this.FileName = openFileDialog.FileName;
        }
    }

    private void OnMediaFailed(object sender, ExceptionRoutedEventArgs e)
    {
        MessageBox.Show(this, e.ErrorException.Message, "Media failed");
    }
}

If I try to open a file with a # in the path from a network drive it fails with:

Exception from HRESULT: 0xC00D11B1

The clip plays fine if I remove the # from the path

What am I doing wrong?

Update: Windows media player plays the clip from network drive with # in the path.

Johan Larsson
  • 17,112
  • 9
  • 74
  • 88

1 Answers1

1

It works fine for me.But as I understand from the error code, It seems like a codec issue.Take a look https://social.msdn.microsoft.com/Forums/vstudio/en-US/2d80888f-4f1d-450c-90ee-2568b7283e23/mediaelement-failing-with-exception-from-hresult-0xc00d11b1?forum=wpf

FreeMan
  • 1,417
  • 14
  • 20
  • Should not be a codec issue as the clip plays fine if I remove the # from the path. – Johan Larsson Sep 20 '16 at 13:17
  • could you please check "Eddie Li - MSFT's answer" in the given link above?Maybe it helps. – FreeMan Sep 20 '16 at 13:19
  • Does the link about error in the source URI work for you? – Johan Larsson Sep 20 '16 at 13:20
  • Actually, your code works for me without doing nothing.I just copied and pasted.It works. But as long as I search the error code you wrote in forums, Eddie Li - MSFT's answer in the link above makes sense.I saw such answers for the error codes on different forums. – FreeMan Sep 20 '16 at 13:23
  • Just to confirm: does the code work for a file on a mapped drive with # in the path? For med it works with # in path when on local disk. Plays fine on network drive without #. – Johan Larsson Sep 20 '16 at 16:33