Assemble an image and video player in Delphi

Asked

Viewed 1,874 times

3

I have a project for college and I don’t know how I can solve it.

The idea is to make a video and image player together, so I can put the images and videos in the same playlist and each item can only run for 15 seconds.

I have a video and image player ready now, only I can’t merge the two to suit me. Follow links of the two projects: https://goo.gl/RyCmgZ

2 answers

2

@Renato_souza_delphi, explaining in a very simple way what I had mentioned in the other answer.

In Delphi in the menu bar go to:

  1. Component / Import / Component.
  2. On the next screen choose the option Import Activex Control.
  3. in the next screen locate in the grid: inserir a descrição da imagem aqui

  4. Select the palette name as you wish I left it as ActiveX.

  5. On the next screen choose the option Install To New Package and finish.
  6. Then check that the component palette you defined earlier was created in Delphi ( step 4 ).
  7. Put in the Form the component TWindowsMediaPlayer of this new palette and a Timer setting it up as long as you want.
  8. Go on the property of TWindowsMediaPlayer and adjust your property Align: alClient.

  9. Follow the code below with a simple implementation, in the line of code containing FLista.Add('arquivo.png') replace the string containing the path of the files you want to present.

Implementation

unit frmPrincipal;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.OleCtrls, WMPLib_TLB, Vcl.StdCtrls,
  Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    wm: TWindowsMediaPlayer;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    FIndex: Integer;
    FLista: TStringList;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  FLista :=  TStringList.Create;
  FIndex := 0;
  FLista.Add('arquivo.png');
  Flista.Add('arquivo.mp3');
  Timer1.Enabled := True;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FreeAndNil( FLista );
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if FIndex > 1 then
    Exit;
  wm.URL := FLista.Strings[FIndex];
  wm.controls.play;
  Inc(FIndex);
end;

end.

This is a simple example of what you can easily do with the Activex windows media player, there are numerous methods and features that you can implement any doubt is just talk, I could not detail and write a consistent code for lack of time but I hope you have caught the idea.

1

Use Activex control from windows media player that solves your problem as it can run videos and open JPEG. Import the ocx that is in the system32 folder and adapt the control to your needs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.