whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

37 Visitors Online


 
... play a mp3 after the other, with 2 components?
Autor: AlexSystems
Homepage: http://www.alexsystems.hpg.com.br
[ Print tip ]  

Tip Rating (19):  
     


unit Unit1;

interface

uses
  
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, MPlayer, ComCtrls, ExtCtrls, StdCtrls;

type
  
TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    MediaPlayer1: TMediaPlayer;
    MediaPlayer2: TMediaPlayer;
    Timer1: TTimer;
    Label1: TLabel;
    ProgressBar1: TProgressBar;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    OpenDialog1: TOpenDialog;
    Label2: TLabel;
    Timer3: TTimer;
    ProgressBar2: TProgressBar;
    Timer4: TTimer;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer3Timer(Sender: TObject);
    procedure Timer4Timer(Sender: TObject);
  private
    
{ Private declarations }
  
public
    
{ Public declarations }
  
end;

var
  
Form1: TForm1;
  PlayerX: string;
  PlayerXXX: string;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  
ProgressBar1.Position := trunc(mediaplayer1.Position / mediaplayer1.Length * 100);
  if mediaplayer1.Position = mediaplayer1.Length then
    
timer1.Enabled := False;


  if ProgressBar1.Position = 100 then    /// para quando acaba o mp3 iniciar outro mp3
  
begin
    
MediaPlayer1.Close;
    PlayerXXX      := Label1.Caption;
    label2.Caption := PlayerXXX;
    MediaPlayer2.FileName := PlayerXXX;
    Mediaplayer2.TimeFormat := tfMilliSeconds;
    MediaPlayer2.Open;
    MediaPlayer2.play;

    button2.Enabled := False;
    button3.Enabled := False;

    timer3.Interval := 100;
  end;
end;



procedure TForm1.Button1Click(Sender: TObject);
begin
  with 
OpenDialog1 do
    
/// abre o dialogo
    
if Execute then 
    begin
      
PlayerX        := OpenDialog1.FileName;
      Label1.Caption := PlayerX;


      with MediaPlayer1 do 
      begin
        
MediaPlayer1.FileName   := PlayerX;
        Mediaplayer1.TimeFormat := tfMilliSeconds;
        MediaPlayer1.Open;
      end;
    end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  
Mediaplayer1.play;
  timer1.Interval := 100;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  
Mediaplayer1.pause;
end;

procedure TForm1.Timer3Timer(Sender: TObject);
begin
  
ProgressBar2.Position := trunc(mediaplayer2.Position / mediaplayer2.Length * 100);
  if mediaplayer2.Position = mediaplayer2.Length then
    
timer3.Enabled := False;
end;

end.

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners