Arsip: Embed sound

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

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;

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

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

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
reply |
Report Obsolete
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
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- help, cara menfreeze posisi form...
by micrens in Form Enhancement & Graphical Controls more 17 years ago - lagi... knp masih pake bajak_an?
by simba in Hal umum tentang Pascal Indonesia more 18 years ago - Mohon Masukan + Pendapat Dari Sesepuh Delphi..
by juan81 in Games more 16 years ago - Menggunakan EventonExit !
by jajang in Tip n Trik Pemrograman more 16 years ago - Cached Update Problem dengan Zeos + MySQL
by archvile in MySQL more 17 years ago - Cetak structure tabel ?
by debby in Hal umum tentang Pascal Indonesia more 17 years ago - backup n upload database
by yayaretina in MySQL more 18 years ago - ADO
by krishy in Tip n Trik Pemrograman more 17 years ago - akses database ms.acces dari delphi
by artati in Paradox more 17 years ago - [Help] Form dgn Back dan Next button
by wahjoew in Hal umum tentang Pascal Indonesia more 18 years ago