Link to home
Start Free TrialLog in
Avatar of redforce
redforce

asked on

Play Mpegmovies with Delphi

I'm writing an mutimedial CD-Rom and want to play some movies. Instead of the standard avi-format I want to use mpeg movies. Is there a free component to manage this?
Avatar of Phoenix_s
Phoenix_s

use the TMediaPlayer component in Delphi (depends which version of delphi you use)  that should play most of the mpegs. Mind you... another gentleman here is having difficulties playing some mpeg formats with delphi 3's TMediaPlayer and that may be an incompatability issue. Other than that, I recommend combing the free component sections of several popular delphi pages... OR... use OLE automation to launch the Windows Media Player with the file you want played.  Windows media player should be the most accurate player of mpegs around, and it will auto download new codecs if needed.
I had same problem. I solved it by putting the setup program for Active Movie on the CD. When the CD  is started I have a small test file to attempt to open (which is not shown) if this is not there then I launch a setup option for Active Movie. I have this in my project source, this is just a snippet as there is allsorts of other things going on.

 try
      Application.ShowMainForm := False;
      with MainForm.MediaPlayer1 do
        begin
          FileName := 'video\test.mpg';
          Open;
        end;
      //my other stuff
      Application.Run;

      except on EMCIDeviceError do
      begin
      s := MessageDlg('You do not appear to have the correct drivers installed'
                + ' for viewing the videos in this software. '
                +'Would you like to install them now?',
                 mtError,[mbOK, mbCancel],MB_TASKMODAL);
        case s of
          1:begin
              Command := 'amov\amov4ie.exe' + #0;
              if WinExec(@command[1], SW_SHOWNORMAL) < 32 then
              MessageDlg('Failed to execute', mtError, [mbOK], 0);
              Application.Terminate;
            end;
          2: Application.Terminate;
      end;

end
  else
  begin
   Application.ShowMainForm := True;
   MainForm.Visible := True;
  end;
  end;
  end;  
Application.Run;  

As I say this isn't a complete piece but hope it gives an idea of what I mean.

cheers
chris
listenning..

Avatar of redforce

ASKER

My code should check like xpher wrote, if the computer could play mpeg files. The best thing would be if it add the code automatic from my programm if needed, so that the user don't see it.
I don't think this can be done without user knowing you are installing to their machine. Plus it is probably only fair to be honest about what you are doing. I have had no negative feedback only positive for the way I achieved it.

regards
xpher ;)
ASKER CERTIFIED SOLUTION
Avatar of TheNeil
TheNeil

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This wont work if codecs etc not installed on user's machine.

xpher