MediaPlayer cannot play file names without an extension

4

When I try to play a local file having no file extension the component System.Windows.Controls.MediaElement fails with a FileNotFoundException saying "Media file download failed.":null. The inner exception is a System.Runtime.InteropServices.COMException with HResult 0xC00D0FEA.

I tried the Uri I assigned to MediaPlayer.Source with WebClient.DownloadData(Uri) and there were no problems with neither the uri nor the returned data.

Update: While I first concentrated on why new Uri(@"c:\temp\filename.") just becomes file:///c:/temp/filename (swallowing the trailing dot) after finally renaming the file to "filename.data" still the very same exception is thrown. I assume that WPF -- which is using Media Foundation, which is newest technology -- uses file name extensions instead of just parsing file data. facepalm

c#
.net
wpf
asked on Stack Overflow Sep 30, 2014 by springy76 • edited Sep 30, 2014 by springy76

1 Answer

0

The problem is that the Media Player uses DirectShow filters to load the file. If there is no extension it does not know which filter to use.

The same error appears if you try and open a stream without a registered scheme.

The schemes are saved in HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\Schemes.

By adding a scheme here it can be opened in the MediaPlayer (as long as the correct filters have been opened)

answered on Stack Overflow Feb 4, 2015 by Joe Sonderegger

User contributions licensed under CC BY-SA 3.0