MediaPlayer cannot play filenames without extension
When I try to play a local file that does not have a file extension, the component System.Windows.Controls.MediaElement
fails with a FileNotFoundException that says "Loading media file". :: null . An internal exception is System.Runtime.InteropServices.COMException
with HResult 0xC00D0FEA.
I tried Uri I assigned MediaPlayer.Source
with WebClient.DownloadData(Uri)
and there was no problem with either the uri or the data returned.
Update: While I initially focused on why it new Uri(@"c:\temp\filename.")
just becomes file:///c:/temp/filename
(swallowing the endpoint) after the file is finally renamed to "filename.data", the same exception is still thrown. My guess is that WPF, which uses Media Foundation, which is the latest technology, uses file name extensions instead of just parsing the file data. Facepalm
source to share
The problem is that Media Player is using DirectShow filters to load the file. If the extension is missing, it doesn't know which filter to use.
The same error appears if you try to open a stream without a registered schema.
Schemes are saved in HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\Schemes
.
By adding schema here, it can be opened in MediaPlayer (as long as correct filters are open)
source to share