excellent thanks guys that did the trick...

well as a further query, Im looking at using threads to run the music
so that it doesnt lock the program during execution (the below code with
the wait moved doesnt return focus to the form until the final song has
been completed)

Is threading what I want to do?

I have the following

  tmythread = class(tthread)
  private
    { Private declarations }
  protected
    { Public declarations }
    procedure Execute; override;
  end;

...........

procedure tmythread.Execute;
begin
  tform1.mediaplayer1.FileName := directorylistbox1.Directory + '\' +
listbox1.items[listbox1.itemindex] + '\' + name;
  tform1.mediaplayer1.Open;
  tform1.mediaplayer1.wait := true;
  tform1.mediaplayer1.Play;
end;

...........

  newthread := tmythread.Create(false);
  try
    for i := 0 to listbox2.items.count-1 do
    begin
      if listbox2.selected[i] then
      begin
  //      while mediaplayer1.mode = mpPlaying do
        begin

        end;
        name := listbox2.Items[i];
        newthread.execute;
      end;
    end;
  finally
    newthread.free;
  end;

but it complains that a method identifier is expected on the first line
in tmythread.execute function.  Im assuming its because Im referencing a
vcl component now in a new thread?  Do I have to make an association of
somekind between the thread and the calling form? or am I just way off
the mark with threads and should rtfm? ;)

Cheers

Chris


>>> [EMAIL PROTECTED] 10/03/2004 11:49:45 a.m. >>>
Have you tried putting the wait before the play?

Dave.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Chris Veale
Sent: Wednesday, 10 March 2004 11:10 a.m.
To: [EMAIL PROTECTED] 
Subject: [DUG]: Tmediaplayer - wait until one complete?


Hi.

Im just mucking around with the Tmediaplayer component, and get it to
play a
song easily enough, but when I want to play a couple in a row, I cant
get it
to play the first one....I loop through a listbox to get the
filenames...

this is what I have, but it loops through just playing the last
one....

  for i := 0 to listbox2.items.count-1 do
  begin
    if listbox2.selected[i] then
    begin
      name := listbox2.Items[i];
      mediaplayer1.FileName := directorylistbox1.Directory + '\' +
listbox1.items[listbox1.itemindex] + '\' + name;
      mediaplayer1.Open;
      mediaplayer1.Play;
      mediaplayer1.Wait := true;
    end;
  end;


Any thoughts?

Cheers

Chris


______________________________________________________
The contents of this e-mail are privileged and/or confidential to the
named
recipient and are not to be used by any other person and/or
organisation. If
you have received this e-mail in error, please notify 
the sender and delete all material pertaining to this e-mail.
______________________________________________________
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi 


_______________________________________________
Delphi mailing list
[EMAIL PROTECTED] 
http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to