Arsip: Embed sound

 
user image
more 18 years ago

wiedhodho

Mas gimana ya caranya tuk embed file sound (mp3,midi, wav) ke dalam file delphi exe kita?
user image
more 18 years ago

deLogic

untuk embed file, Anda dapat menyimpannya sebagai resource. Ini ada contoh snippet code, saya ambil dari TipsExplorer2007. Anda tinggal melakukan modifikasi saja dan membuat prosedur untuk memproses file musik Anda (play, dan sebagainya)

{
Ever wanted to hide files inside your application ? Well, it is possible.
Inprise does actually ship an editor with delphi which is capable of compiling
any file in to a resource. The name of this compiler (In delphi 4 anyway) is
BRCC32.EXE and can be found in the \program files\borland\delphi4\bin directory.
I will now give an example of how to embed your files, and then how to use these
files.
Stage 1, making the RES
- Open a DOS window
- Change to your delphi\bin directory
- type Edit MyRes.RC and type the following :
       clouds   rcdata   c:\windows\clouds.bmp
- Save your file
- Exit back to your DOS window
- Type brcc32 MyRes
You now have a file called MyRes.Res. Clouds is your ID for the resource item,
rcdata tells the compiler that this is a binary file, and the last paramter is
the file you want included. You may have as many lines as you like in your RC
file, as long as the ID is unique.

Stage 2, using the RES
- Copy the RES file to your application directory
- In the unit code for your main form you will see
}
        {$R .DFM}
// - You need to change this to
        {$R  .DFM}
        {$R MyRes.Res}
{
- Drop a TImage on your main form
- In the OnCreate method of your form do the following :
}
procedure TForm1.FormCreate(Sender: TObject);
var
  //We need a stream to read our resource
  RS : TResourceStream;
begin
  //Open resource item named "Clouds"
  RS := TResourceStream.Create(HInstance,'Clouds',RT_RCDATA);
  try
    //Load our Image from our ResourceStream
    Image1.Picture.Bitmap.LoadFromStream(RS);  //Load the bitmap from our stream
  finally
    //Free the memory used for our stream
    RS.Free;
    end;
end;
// On the other hand, you may extract these items to disk using the following code :
procedure TForm1.FormCreate(Sender: TObject);
var
  //Obviously we need our Resource Stream
  RS : TResourceStream;
  //Also we need a File stream to write to disk with
  FS : TFileStream;
begin
  //Open our resource
  RS := TResourceStream.Create(HInstance,'Clouds',RT_RCDATA);
  //Create our file
  FS := TFileStream.Create('c:\newfile.bmp', fmCreate);
  try
    //Copy from Resource to Disk
    FS.CopyFrom(RS,RS.Size);
  finally
    FS.Free;
    RS.Free;
  end;
end;
user image
more 18 years ago

jrp

Bisa juga pakai salah satu komponen dari paket JVCL. Tapi sori saya lupa namanya... jrp
user image
more 18 years ago

int2k

kalo yang jvcl kalo gak salah jvembedded dari situ bisa di simpan ke stream ato di save ke file
user image
more 18 years ago

sorrow

klo play musik bisa pake komponen mplayer, hee..
user image
more 17 years ago

wongUedanTenan

Lha itu pan udeh cukup nerangin bgt post-nya deLogic, yg penting cuma, kita mo simpen dulu tuh file ke disk atau langsung loadfromstream. Buat componen sound, cari di source forge, perasaan ada deh buat mpeg.. itu kalo mo pake format mp3. buat nge-embeded mah (kalo rajin) bikin aja file .res dari .rc data type RCDATA. compile trus include ke source code. bikin res : BRCC32 namafile.rc -> namafile.res embeding : {$R namafile.res}
more ...
  • Pages:
  • 1
Share to

AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com