Showing posts with label multimedia. Show all posts
Showing posts with label multimedia. Show all posts

Question:
I wish to be able have an application to record sound and store to wav.
Could you show me?

Answer:
This application using Windows API and using mmsystem as the engine.
Please try this codes:


uses mmSystem;
{....}

procedure TForm1.Button1Click(Sender: TObject); // Record
begin
mciSendString('OPEN NEW TYPE WAVEAUDIO ALIAS mysound', nil, 0, Handle);
mciSendString('SET mysound TIME FORMAT MS ' + // set time
'BITSPERSAMPLE 8 ' + // 8 Bit
'CHANNELS 1 ' + // MONO
'SAMPLESPERSEC 8000 ' + // 8 KHz
'BYTESPERSEC 8000', // 8000 Bytes/s
nil, 0, Handle);
mciSendString('RECORD mysound', nil, 0, Handle)
end;

procedure TForm1.Button2Click(Sender: TObject); // Stop
begin
mciSendString('STOP mysound', nil, 0, Handle)
end;

procedure TForm1.Button3Click(Sender: TObject); // Save
var
verz: String;
begin
GetDir(0, verz);
mciSendString(PChar('SAVE mysound ' + verz + '/test.wav'), nil, 0, Handle);
mciSendString('CLOSE mysound', nil, 0, Handle)
end;

Question:
Umm, I want to play windows system sound ....

Answer:
Ok, use this tiny systax.
This example is to play sound of SYSTEMSTART, you may change to other sound.

uses
MMSystem;


PlaySound(PChar('SYSTEMSTART'), 0, SND_ASYNC);
{
Other System sounds:
Andere Systemsounds:
SYSTEMSTART
SYSTEMEXIT
SYSTEMHAND
SYSTEMASTERISK
SYSTEMQUESTION
SYSTEMEXCLAMATION
SYSTEMWELCOME
SYSTEMDEFAULT
}


Question:
Is it possible to bouild my own swf to exe converter with delphi?

Answer:
Since delphi is the greatest programming language,
anything is possible, include make simple swf converter.
Here the code. Its top secret.


function Swf2Exe(S, D, F: string): string;
var
SourceStream, DestinyStream, LinkStream: TFileStream;
flag: Cardinal;
SwfFileSize: Integer;
begin
Result := 'something error';
DestinyStream := TFileStream.Create(D, fmCreate);
try
LinkStream := TFileStream.Create(F, fmOpenRead or fmShareExclusive);
try
DestinyStream.CopyFrom(LinkStream, 0);
finally
LinkStream.Free;
end;
SourceStream := TFileStream.Create(S, fmOpenRead or fmShareExclusive);
try
DestinyStream.CopyFrom(SourceStream, 0);
flag := $FA123456;
DestinyStream.WriteBuffer(flag, SizeOf(Integer));
SwfFileSize := SourceStream.Size;
DestinyStream.WriteBuffer(SwfFileSize, SizeOf(Integer));
Result := '';
finally
SourceStream.Free;
end;
finally
DestinyStream.Free;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Swf2Exe('c:\somefile.swf', 'c:\somefile.exe',
'c:\Program Files\Macromedia\Flash MX\Players\SAFlashPlayer.exe');
end;

CLICK TO REGISTER