问题
I want to play a video in Delphi. This is the code that I've got:
if OpenDialog1.Execute then
begin
MediaPlayer1.FileName:=OpenDialog1.FileName;
MediaPlayer1.Open;
MediaPlayer1.Display:=pnlVideo;
MediaPlayer1.Play;
end;
But I get an error message:'The specified file cannot be played on the specified MCI device.The file may be corrupt, not in the correct format or no available file handler available for this format.' The format of the video that I use is avi. All help is appreciated.
回答1:
There is a compatibility issue with the media player component in Delphi on our "modern" computers. I'm not tech savvy on what exactly the problem is :P. It is best to make your own component in Delphi to play media.
This link can help you make a Windows Media Player component, or you can adjust it to make another active X media player component - such as VLC.
https://chapmanworld.com/windows-media-player-in-delphi/
I hope this will help. :D
来源:https://stackoverflow.com/questions/45661792/how-to-make-a-basic-media-player-to-play-a-video-in-avi-format