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
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)
User contributions licensed under CC BY-SA 3.0