?
Solved

Using TMediaPlayer to Play Wave File Sequentially..., Second after first wave file finished.

Posted on 2003-03-17
4
Medium Priority
?
320 Views
Last Modified: 2010-08-05
   I've problems using TMediaplayer to play Wave file
    1. I have wave files like this... Wav1.Wav, Wav2.Wav, ... and so on.
    2. I want to play continueous wave phrase recorded in each wave files but problems arise
       When I use TMediaplayer, I named it "Media1" and put the code like this
       with Media1 do begin
          Close;
          FileName := 'C:\Wav1.Wav';
          Open;
          Play;

          FileName := 'C:\Wav2.Wav';
          Open;
          Play;
         
          ... and so on
       End;
   Problems is that Media1 doesn't seem to play Wav1.wav, it only play the last file in the code.
What I know for sure is that the code excuted simultaneously after it play the first file, it execute the next command immediately. That is, it stop playing the first file and immediately play the second file. That make the code unacceptable. I've tried using
   Media1.Wait := True;
   Media1.Play;
   It doesn't seem to work. Result is the same as before.
   So tell me how to make it play the first file till it finished. Then play the second file so that it result in sequentially voice...
0
Comment
Question by:DOOM_DAEMON
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 8152755
Hi,

Try

...
Wait := true;
Play;
...

This is not recommended if the palyed media is long.

Regards, Geo
0
 
LVL 3

Accepted Solution

by:
tongalite earned 200 total points
ID: 8154355
Hi,
Try this.

Good luck
T.
=======================

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    MediaPlayer1: TMediaPlayer;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  filename:string;
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin

  with MediaPlayer1 do
  begin
    FileName := 'C:\windows\media\ding.wav';
    AutoRewind := True;

      Open;          { Open Media Player }
      Wait := True;  { Waits until sounds is done playing to return }
      Play;          { Play sound }
      Play;          { Play again after first playing is completed }


    FileName := 'C:\windows\media\chord.wav';
    AutoRewind := True;

      Open;          { Open Media Player }
      Wait := True;  { Waits until sounds is done playing to return }
      Play;          { Play sound }
      Play;          { Play again after first playing is completed }

   FileName := 'C:\windows\media\chimes.wav';
   AutoRewind := True;

      Open;          { Open Media Player }
      Wait := True;  { Waits until sounds is done playing to return }
      Play;          { Play sound }
     Close;
     end;
         end;
             end.
0
 
LVL 1

Author Comment

by:DOOM_DAEMON
ID: 8157173
   I now Know where problems are. Because of placing Wait := True before Open; like this
    FileName := 'C:\Windows\Media\Chimes.wav';
    Wait := true;
    Open;
    Play;

    That cause the program to run like wait:= false; After doing code like you, it works! Thanks. And thanks to all of you helping me here.
0
 
LVL 17

Expert Comment

by:geobul
ID: 8157503
Hi DOOM_DAEMON,

What's wrong with my comment? The key was setting Wait to true before Open. I think I pointed that out first. The accepted answer will play each file twice. Is that what you are looking for?

Regards, Geo
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question