Enej
asked on
MediaPlayer
Few questions:
- I would like my application to play
*.mdi files randomely one after another.
(One finishes and another starts).How?
- One and the same *.mdi plays all the time.How?
- I would like my App. to play *.wav
as soon as Label1.Caption 'Good!'
is displayed.Can seem to get it to work
because when i write after Label1...
MediaPlayer1.Play (Autoopen and Active is set to true),it does not seem to work.
Is it possible to have MPlayer detect caption words and play?
- I would like my application to play
*.mdi files randomely one after another.
(One finishes and another starts).How?
- One and the same *.mdi plays all the time.How?
- I would like my App. to play *.wav
as soon as Label1.Caption 'Good!'
is displayed.Can seem to get it to work
because when i write after Label1...
MediaPlayer1.Play (Autoopen and Active is set to true),it does not seem to work.
Is it possible to have MPlayer detect caption words and play?
This are 4!!! questions
>>Is it possible to have MPlayer detect caption words and play?
Use a timer
Use a timer
you want play midi recycle?
put a timer on your form, and examine the mediaplayer.mode, if these value equal mpStopped, then you can rewind midi, and replay it .like these , you can play another midifile.
if you want play a wav when label display, try using sndPlaySound API instead Mediaplayer.
put a timer on your form, and examine the mediaplayer.mode, if these value equal mpStopped, then you can rewind midi, and replay it .like these , you can play another midifile.
if you want play a wav when label display, try using sndPlaySound API instead Mediaplayer.
ASKER
Detailed answer pleae....
ASKER
Adjusted points to 60
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ehmmm...
and fill the listBox for this examle with e.g.
C:\Win95\Media\Chord.wav
C:\Win95\Media\Canyon.mid
C:\Win95\Media\Ctmelody.wa v
C:\programme\creative\ctsn d\samples\ reggae.mid
C:\programme\creative\ctsn d\samples\ ballade.mi d
cheers
Indi
and fill the listBox for this examle with e.g.
C:\Win95\Media\Chord.wav
C:\Win95\Media\Canyon.mid
C:\Win95\Media\Ctmelody.wa
C:\programme\creative\ctsn
C:\programme\creative\ctsn
cheers
Indi
Ooops
and delete the integers randomInd and Index
and delete the integers randomInd and Index
O Oh.. again
cause you can't close a not yet opened player, please, not to use it twice make the stopbutton invisible or so...
This is only an example how all can work, perhaps there are tiny bugs, just figure it out.
good luck
Indi
cause you can't close a not yet opened player, please, not to use it twice make the stopbutton invisible or so...
This is only an example how all can work, perhaps there are tiny bugs, just figure it out.
good luck
Indi
ASKER
Actually, what I am trying to do is this:
Have the music play continuously while my application is running.
All the music files are in a separate folder :(C:\Music)and the application should load /play them randomely in continuous.Eliminating the music is
done by means of a menu with(checkbox)
(If checked true then music play else
music stop).That is all!
Any help???
Have the music play continuously while my application is running.
All the music files are in a separate folder :(C:\Music)and the application should load /play them randomely in continuous.Eliminating the music is
done by means of a menu with(checkbox)
(If checked true then music play else
music stop).That is all!
Any help???
First read all files into the listbox
If you don't know how, i tell you
THAT'S ANOTHER QUESTION !!!
and then
put into procedure TForm1.FormActivate(Sender : TObject);
or better FormCreate
If Musikcheck.State = cbchecked Then
begin
........load and play randomly WITHIN A TIMER !!!
// you do have all the stuff you need for this ,see up above !
else
stopbuttonclick //see above
I think you don't wanna let somebody write the whole thing for you
Use your brain, you are a programmer, aren't you !
Indi
If you don't know how, i tell you
THAT'S ANOTHER QUESTION !!!
and then
put into procedure TForm1.FormActivate(Sender
or better FormCreate
If Musikcheck.State = cbchecked Then
begin
........load and play randomly WITHIN A TIMER !!!
// you do have all the stuff you need for this ,see up above !
else
stopbuttonclick //see above
I think you don't wanna let somebody write the whole thing for you
Use your brain, you are a programmer, aren't you !
Indi
Ok, did not realize that you increased the points
this is by M_Adil
procedure FindFile(PathFileName : string; IncludeSubDirs : Boolean);
var
srec : TSearchRec;
Path, FileName : String;
begin
Path := ExtractFilePath(PathFileNa me); // give one name
FileName := ExtractFileName(PathFileNa me);
// CurrentDirectory
if findfirst(PathFileName,faa nyfile,sre c) = 0 then
begin
repeat
If Not(srec.attr and fadirectory > 0) then
begin
if ExtractFileExt((Srec.Name) )= myExt then
begin
//Do something, get the name (Srec.Name)
//inc a counter or add to Listbox1 !!!
end;
end;
Until findnext(srec) <> 0;
end;
FindClose(SRec);
{ SubDirectories }
If IncludeSubDirs then
begin
if FindFirst(Path+'*.*',FaAny File,Srec) = 0 then
begin
repeat
// StartRecursion
if not(Srec.Name[1] = '.') and (srec.attr and fadirectory > 0)then
FindFile(Path + Srec.Name + '\' + FileName,IncludeSubDirs)
Until findnext(srec) <> 0;
end;
FindClose(SRec);
end;
Hope, that you can do it now
regards
Indi
this is by M_Adil
procedure FindFile(PathFileName : string; IncludeSubDirs : Boolean);
var
srec : TSearchRec;
Path, FileName : String;
begin
Path := ExtractFilePath(PathFileNa
FileName := ExtractFileName(PathFileNa
// CurrentDirectory
if findfirst(PathFileName,faa
begin
repeat
If Not(srec.attr and fadirectory > 0) then
begin
if ExtractFileExt((Srec.Name)
begin
//Do something, get the name (Srec.Name)
//inc a counter or add to Listbox1 !!!
end;
end;
Until findnext(srec) <> 0;
end;
FindClose(SRec);
{ SubDirectories }
If IncludeSubDirs then
begin
if FindFirst(Path+'*.*',FaAny
begin
repeat
// StartRecursion
if not(Srec.Name[1] = '.') and (srec.attr and fadirectory > 0)then
FindFile(Path + Srec.Name + '\' + FileName,IncludeSubDirs)
Until findnext(srec) <> 0;
end;
FindClose(SRec);
end;
Hope, that you can do it now
regards
Indi
ASKER
First read all files into the listbox
If you don't know how, i tell you
THAT'S ANOTHER QUESTION !!!
///I do not know !
Use your brain, you are a programmer, aren't you !
///Not really,just a beginner trying to learn something...
If you don't know how, i tell you
THAT'S ANOTHER QUESTION !!!
///I do not know !
Use your brain, you are a programmer, aren't you !
///Not really,just a beginner trying to learn something...
Well, Enej,
Maybe i have been too rough...
and so i made a mistake, too
Sorry for that
and so i made it for you
unit Musikplayer1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, MPlayer, ExtCtrls;
type
TForm1 = class(TForm)
MusikCheck: TCheckBox;
ListBox1: TListBox;
Timer1: TTimer;
MediaPlayer1: TMediaPlayer;
procedure FormCreate(Sender: TObject);
procedure FindFile(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MusikCheckClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
myExt : string;
PathFileName,Path, FileName : String;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
PathFileName :='C:\win95\media\*.*';
MyExt:='.wav'; // whatever
FindFile(Form1);
MyExt:='.mid'; // whatever
FindFile(Form1);
Mediaplayer1.autoOpen := true;
mediaplayer1.DeviceType:=d tAutoSelec t;
MediaPlayer1.FileName :=Path + ListBox1.Items.Strings[ran dom(ListBo x1.Items.C ount - 1)];
mediaplayer1.open;
MusikCheckClick(form1);
end;
procedure TForm1.FindFile(Sender: TObject);
var
srec : TSearchRec;
begin
Path := ExtractFilePath(PathFileNa me);
FileName := ExtractFileName(PathFileNa me);
if findfirst(PathFileName,faa nyfile,sre c) = 0 then
begin
repeat
If Not(srec.attr and fadirectory > 0) then
begin
if ExtractFileExt((Srec.Name) )= myExt then
begin
ListBox1.Items.Add(Srec.Na me);
end;
end;
Until findnext(srec) <> 0;
end;
FindClose(SRec);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Interval := 100;
Timer1.Enabled := True;
case Mediaplayer1.mode of
mpPlaying :
begin
Timer1.Enabled := True;
end;
mpStopped :
begin
Mediaplayer1.Close;
MediaPlayer1.FileName :=Path + ListBox1.Items.Strings[ran dom(ListBo x1.Items.C ount - 1)];
Mediaplayer1.open;
Mediaplayer1.play;
end;
end;
end;
procedure TForm1.MusikCheckClick(Sen der: TObject);
begin
If MusikCheck.State = cbchecked Then
begin
Timer1Timer(form1);
end
else
begin
Timer1.enabled:=false;
mediaplayer1.Stop;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Timer1.enabled:=false;
mediaplayer1.Stop;
Mediaplayer1.Close;
end;
end.
Hope this helps now
keep on learning, so do i
CIAO
Indi
Maybe i have been too rough...
and so i made a mistake, too
Sorry for that
and so i made it for you
unit Musikplayer1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, MPlayer, ExtCtrls;
type
TForm1 = class(TForm)
MusikCheck: TCheckBox;
ListBox1: TListBox;
Timer1: TTimer;
MediaPlayer1: TMediaPlayer;
procedure FormCreate(Sender: TObject);
procedure FindFile(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure MusikCheckClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
myExt : string;
PathFileName,Path, FileName : String;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
PathFileName :='C:\win95\media\*.*';
MyExt:='.wav'; // whatever
FindFile(Form1);
MyExt:='.mid'; // whatever
FindFile(Form1);
Mediaplayer1.autoOpen := true;
mediaplayer1.DeviceType:=d
MediaPlayer1.FileName :=Path + ListBox1.Items.Strings[ran
mediaplayer1.open;
MusikCheckClick(form1);
end;
procedure TForm1.FindFile(Sender: TObject);
var
srec : TSearchRec;
begin
Path := ExtractFilePath(PathFileNa
FileName := ExtractFileName(PathFileNa
if findfirst(PathFileName,faa
begin
repeat
If Not(srec.attr and fadirectory > 0) then
begin
if ExtractFileExt((Srec.Name)
begin
ListBox1.Items.Add(Srec.Na
end;
end;
Until findnext(srec) <> 0;
end;
FindClose(SRec);
end;
procedure TForm1.Timer1Timer(Sender:
begin
Timer1.Interval := 100;
Timer1.Enabled := True;
case Mediaplayer1.mode of
mpPlaying :
begin
Timer1.Enabled := True;
end;
mpStopped :
begin
Mediaplayer1.Close;
MediaPlayer1.FileName :=Path + ListBox1.Items.Strings[ran
Mediaplayer1.open;
Mediaplayer1.play;
end;
end;
end;
procedure TForm1.MusikCheckClick(Sen
begin
If MusikCheck.State = cbchecked Then
begin
Timer1Timer(form1);
end
else
begin
Timer1.enabled:=false;
mediaplayer1.Stop;
end;
end;
procedure TForm1.FormDestroy(Sender:
begin
Timer1.enabled:=false;
mediaplayer1.Stop;
Mediaplayer1.Close;
end;
end.
Hope this helps now
keep on learning, so do i
CIAO
Indi
Hi, thanks for the comments. <a href="http://www.randomind.com">http://www.randomind.com</a>