Naum
2009-02-07 10:37:06
A little SCAR .wav player I put together, origonally based on SmartzKid's SoundBoard but I added alot of extra features into this. It only plays one song atm, which is a real problem.
Enjoy.
I might make it play 2 songs later on. If you know how to make it play more than one, Please PM me. Thanks!
Enjoy.
{Used Play Current song from SmartzKid's SoundBoard V2}
program WAVPlay0r;
var
// MusicForm variables.
EndMusicForm : Boolean;
frmDesign : TForm;
Label1, Label20 : TLabel;
GroupBox1 : TGroupBox;
ListBox1 : TListBox;
Button1, Button2, Button3, Button4,
Button5, Button6, Button7 : TButton;
Edit1 : TEdit;
Sounds : Array Of String;
M : Integer;
Timer : TTimer;
SoundDur, SoundStart : Integer;
SongProg : TProgressBar;
Function Browse : Array Of String; //Thx Da 0wner
var
OpenDialog1 : TOpenDialog;
begin
OpenDialog1 := TOpenDialog.Create(Nil);
OpenDialog1.InitialDir:='C:\WINDOWS\Media';
OpenDialog1.Title := 'SCAR Wav Player - Select Music!';
OpenDialog1.Filter := 'Wav Music Files (.wav)| *.wav';
if OpenDialog1.Execute then
SetLength(Result, OpenDialog1.Files.Count);
For M := 0 to OpenDialog1.Files.Count - 1 Do
Result[M] := OpenDialog1.Files.Strings[M];
OpenDialog1.Free;
end;
procedure PlayCurrentSound;
begin
if(ListBox1.Itemindex > -1)then
begin
SoundDur := GetSoundDuration(Sounds[ListBox1.Itemindex]);
SoundStart := GetSystemTime;
PlaySound(Sounds[ListBox1.Itemindex]);
Timer.Enabled := True;
end;
end;
Procedure OkiClick(Sender : TObject);
Begin
Case Sender Of
Button1 : ListBox1.Items.Clear;
Button2 : ListBox1.Items.Delete(ListBox1.ItemIndex) ;
Button3 : PlaySound('.wav');
Button4, ListBox1 : PlayCurrentSound;
Button5 : Begin
Sounds := Browse;
For M := 0 to High(Sounds) Do
ListBox1.Items.Add(ExtractFileName(Sounds[M]));
end;
Button6 : Begin
FrmDesign.Close;
PlaySound('.wav');
end;
Button7 : OpenWebPage('http://www.villavu.com/forum/showthread.php?t=41676?t=44631');
End;
End;
Procedure UpdateProgressbar;
begin
try
SongProg.Position := Ceil((GetSystemTime - SoundStart) / SoundDur * 100);
except
end;
if((GetSystemTime - SoundStart) > Round(SoundDur))then
begin
Timer.Enabled := false;
SongProg.Position := 0;
end;
end;
Procedure Update;
Begin
Label20.Caption := ('Song Status(s) | ' +FloatToStr(Ceil(((GetSystemTime - SoundStart) / 60) / 10))+' / '+FloatToStr(Ceil((SoundDur/60) / 10)));
end;
Procedure UpdateProgressBar1(Sender4 : TObject);
var V : TVariantArray;
begin
V := [];
SetArrayLength(V, 0);
ThreadSafeCall('Update', v);
ThreadSafeCall('UpdateProgressBar', v);
end;
// This form was parsed using: DFM Form Parser v.25 by Ron.
procedure MusicForm;
var
TimeMusicForm : Integer;
begin
TimeMusicForm := GetSystemTime;
frmDesign := CreateForm;
with frmDesign do
begin
Position := poScreenCenter;
BorderStyle := bsNew;
BorderIcons := [biMinimize];
ClientWidth := 376;
ClientHeight := 192;
Caption := ' SCAR Music Player (.wav file only)';
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'MS Sans Serif';
Font.Style := [];
PixelsPerInch := 96;
end;
Label1 := TLabel.Create(frmDesign);
with Label1 do
begin
Parent := frmDesign;
Left := 192;
Top := 16;
Width := 169;
Height := 13;
Caption := 'Music Play List (.wav Files ONLY!!)';
end;
GroupBox1 := TGroupBox.Create(frmDesign);
with GroupBox1 do
begin
Parent := frmDesign;
Left := 6;
Top := 8;
Width := 363;
Height := 177;
Caption := 'SCAR Music Player';
TabOrder := 17;
end;
ListBox1 := TListBox.Create(frmDesign);
with ListBox1 do
begin
Parent := frmDesign;
Left := 192;
Top := 32;
Width := 169;
Height := 121;
ItemHeight := 13;
TabOrder := 8;
OnDblClick := @OkiClick;
end;
Button1 := TButton.Create(frmDesign);
with Button1 do
begin
Parent := frmDesign;
Left := 120;
Top := 32;
Width := 65;
Height := 25;
Caption := 'Remove All';
TabOrder := 9;
OnClick := @OkiClick;
end;
Button2 := TButton.Create(frmDesign);
with Button2 do
begin
Parent := frmDesign;
Left := 115;
Top := 64;
Width := 75;
Height := 25;
Caption := 'Remove Song';
TabOrder := 10;
OnClick := @OkiClick;
end;
Button3 := TButton.Create(frmDesign);
with Button3 do
begin
Parent := frmDesign;
Left := 115;
Top := 96;
Width := 75;
Height := 25;
Caption := 'Stop Song';
TabOrder := 11;
OnClick := @OkiClick;
end;
Button4 := TButton.Create(frmDesign);
with Button4 do
begin
Parent := frmDesign;
Left := 120;
Top := 128;
Width := 65;
Height := 25;
Caption := 'Play';
TabOrder := 8;
OnClick := @OkiClick;
end;
Button5 := TButton.Create(frmDesign);
with Button5 do
begin
Parent := frmDesign;
Left := 8;
Top := 32;
Width := 97;
Height := 41;
Caption := 'Browse Music File';
TabOrder := 13;
OnClick := @OkiClick;
end;
Button6 := TButton.Create(frmDesign);
with Button6 do
begin
Parent := frmDesign;
Left := 8;
Top := 88;
Width := 97;
Height := 41;
Caption := 'Exit Program';
TabOrder := 14;
OnClick := @OkiClick;
end;
Button7 := TButton.Create(frmDesign);
with Button7 do
begin
Parent := frmDesign;
Left := 8;
Top := 144;
Width := 97;
Height := 41;
Caption := 'Visit Thread';
TabOrder := 15;
OnClick := @OkiClick;
end;
SongProg := TProgressBar.Create(GroupBox1);
with SongProg do
begin
Parent := GroupBox1;
Left := 216 + 10;
Top := 152;
Width := 127;
Height := 17;
TabOrder := 0;
Min := 0;
Max := 100;
end;
Label20 := TLabel.Create(GroupBox1);
with Label20 do
begin
Parent := GroupBox1;
Left := 112;
Top := 152;
Width := 69;
Height := 13;
Caption := 'Song Status | 0 / 0 ';
end;
Timer := TTimer.Create(frmDesign);
with Timer do
begin
Enabled := false;
Interval := 1;
OnTimer := @UpdateProgressbar1;
end;
WriteLn('MusicForm compiled in ' + IntToStr(GetSystemTime - TimeMusicForm) + ' milliseconds!');
end;
procedure SafeMusicForm;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('MusicForm', V);
end;
procedure ShowMusicFormModal;
begin
frmDesign.ShowModal;
end;
procedure SafeShowMusicFormModal;
var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('ShowMusicFormModal', V);
end;
procedure MainMusicForm;
begin
try
SafeMusicForm;
SafeShowMusicFormModal;
finally
FreeForm(frmDesign);
end;
end;
begin
ClearDebug;
If GetSCARVersion >= 300 Then
WriteLn('SCAR can run this')
Else
WriteLn('Please Upgrade to SCAR Divi :)');
MainMusicForm;
end.I might make it play 2 songs later on. If you know how to make it play more than one, Please PM me. Thanks!