问题
I am trying to play a mp3 file from Firemonkey XE7 windows application. It should have been a simple task by putting a TMediaPlayer component, assigning it a .mp3 file, and just playing it. However, I get the following error:
Application Error
Exception EReadError in module MediaPlayerTest.exe at 00000000000012139E.
Error reading MediaPlayer1.FileName: Unsupported media file testfile.mp3.
I have also tried .wav, and it didn't work either. (Audio codec have already been installed and the media files can successfully be played by windows media player.)
I then try compiling the very same program on another computer, and it can be compiled successfully and the mp3 plays just fine.
Does anyone know why it doesn't compile on one computer but does on another?
回答1:
XE7 used DirectX for audio/video playback. Likely something is messed up with your directx installation. I noticed this problem first on a VMWare virtual machine, TMediaPlayer is unable to play anything all file types are unsupported. However same program running on my host worked fine.
Try reinstalling DirectX.
回答2:
Same problem here In a VM, host machine.. tested on a few other PC's as well with the same result. Delphi 10.2.
I tracked it down to TWindowsMedia.InitVideoMixingRenderer9 in FMX.Media.Win which includes this in calculating Result:
Succeeded(FVMRFilterConfig9.SetRenderingMode(VMR9Mode_Windowless));
GetLastError returns 126,
ERROR_MOD_NOT_FOUND
126 (0x7E)
The specified module could not be found.
Changing that call to pass in VMR9Mode_Renderless works (at least for me). I didn't dig into the why/what of this. I'm also just playing audio, no video.
Just thought I'd pass along a workaround in case it's helpful.
回答3:
I've got some very similar errors.
And there are more than one cases:
Problem in mp3. Some Mp3 is unsopported by standard TMediaPlayer. May be it can be fixed by registering of your codec (view list item 3)
If you tried to use TMedia you can't open any media file until you not created TMediaPlayer in any place of your code and filled its FileName property. It's very strange, because
TMediaCodecManager.RegisterMediaCodecClass('.mp3', SVMP3Files, TMediaType.Audio, TWindowsMediaCodec);
is called if you have FMX.Media in uses.Problems in codecs. You can find example in FMX.Media.Win unit, how to register new codec for your app.
Hope this information will help you.
回答4:
It appears to be a limitation of Direct X when installed in a VM. I installed a different media codec (the basic k-lite codec pack) and the player worked fine after that without any code changes. Also, filed a bug report so hopefully R&D can address it
回答5:
I'm not familiar with XE7, but in earlier versions the TMediaplayer used the windows mediaplayer. So the behaviour relies on the actual installed version of the windows player on the computer. This explains the different behaviour on the two computer. You also can use an external player such as real player or other. Use shellexecute to start the external player. Third party player give more details to run mp3.
来源:https://stackoverflow.com/questions/28910428/tmediaplayer-error-unsupported-media-file