Grafika computer memainkan peranan penting dalam sistem multimedia. Yang dimaksud multimedia dalam konteks ini adalah program yang mampu menjalankan file-file dari berbagai bentuk, mulai dari format teks, sound, image, bahkan video. Untuk merancang multimedia, Borland C++ Builder telah menyediakan komponen khusus yaitu media player.
SOURCE CODE :
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
#pragma resource "*.dfm"
TForm1 *Form1; //
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BTGantiClick(TObject *Sender)
{
if (OpenDialog1->Execute()) // SAAT BUTTON GANTI DI EKSEKUSI MAKA AKAN MUNCUL OPEN DIALOG.
MediaPlayer1->FileName=OpenDialog1->FileName;
MediaPlayer1->Open();
MediaPlayer1->Display=Panel1; //MEMBUKA MEDIA PLATYER 1 PADA PANEL
RB2->Enabled=True; // KARENA TRUE MAKA SAAT MEDIA PLAYER LOAD BISA DI KLIK
RB3->Enabled=True; // KARENA TRUE MAKA SAAT MEDIA PLAYER LOAD BISA DI KLIK
RB4->Enabled=True; // KARENA TRUE MAKA SAAT MEDIA PLAYER LOAD BISA DI KLIK
}
// BATAS SCRIPNYA JIKA DI EKSEKUSI MAKA AKA MEMANGGGIL BTGANTI.
//---------------------------------------------------------------------------
void __fastcall TForm1::RB2Click(TObject *Sender)
{
RB3->Enabled=False; //AGAR SAAT RB2 DIKLIK MAKA RB3 TIDAK BISA DI KLIK
RB4->Enabled=False;
MediaPlayer1->Stop();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
MediaPlayer1->Wait=True;
MediaPlayer1->Play(); //SAAT DI PLAY SEMUA BATTON MENGALAMI TRUE DAN FALSE
RB2->Enabled=True;
RB3->Enabled=True;
RB4->Enabled=True;
RB2->Enabled=False;
RB3->Enabled=False;
RB4->Enabled=False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RB3Click(TObject *Sender)
{
RB2->Enabled=False;
RB4->Enabled=False;
MediaPlayer1->Stop();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
RB2->Enabled=True;
RB3->Enabled=True;
RB4->Enabled=True;
RB2->Enabled=False;
RB3->Enabled=False;
RB4->Enabled=False;
}
// FILE PADA SAAT DI JALANKAN AKAN MENGULANG LANGKAHNYA SEBANYAK 3 KALI
//---------------------------------------------------------------------------
void __fastcall TForm1::RB4Click(TObject *Sender)
{
RB2->Enabled=False;
RB3->Enabled=False;
MediaPlayer1->Stop();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
MediaPlayer1->Wait=True;
MediaPlayer1->Play();
RB2->Enabled=True;
RB3->Enabled=True;
RB4->Enabled=True;
RB2->Enabled=False;
RB3->Enabled=False;
RB4->Enabled=False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RBAVYClick(TObject *Sender)
{
OpenDialog1->FileName="";
OpenDialog1->Filter="Audio Video(*.avi)|*.avi";
if (OpenDialog1->Execute())
MediaPlayer1->Close();
BTGanti->Enabled=True;
MediaPlayer1->DeviceType=dtAVIVideo; // MediaPlayer1 MEMBACA dtAVIVideo YAITU EXTENSI .avi
MediaPlayer1->FileName=OpenDialog1->FileName;
MediaPlayer1->Open();
Panel2->Caption="Gambar Yang bagus"; // akan muncul tulisan "Gambar Yang bagus" pada panel2 jika kita membuka file.
MediaPlayer1->Display=Panel1;
Panel5->Caption=OpenDialog1->FileName;
RB2->Enabled=True;
RB3->Enabled=True;
RB4->Enabled=True;
RB2->Checked=False;
RB3->Checked=False;
RB4->Checked=False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RBWAVClick(TObject *Sender)
{
OpenDialog1->FileName="";
OpenDialog1->Filter="WAV Audio Files (*.wav)|*.wav";
if (OpenDialog1->Execute())
MediaPlayer1->Close();
BTGanti->Enabled=True;
MediaPlayer1->DeviceType=dtWaveAudio;
MediaPlayer1->FileName=OpenDialog1->FileName;
MediaPlayer1->Open();
Panel2->Caption="Maaf tidak ada gambar";
MediaPlayer1->Display=Panel1;
Panel5->Caption=OpenDialog1->FileName;
RB2->Enabled=True;
RB3->Enabled=True;
RB4->Enabled=True;
RB2->Checked=False;
RB3->Checked=False;
RB4->Checked=False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RBMIDIClick(TObject *Sender)
{
OpenDialog1->FileName="";
OpenDialog1->Filter="Midi Files(*.midi)|*.midi";
if (OpenDialog1->Execute())
MediaPlayer1->Close();
BTGanti->Enabled=True;
MediaPlayer1->DeviceType=dtSequencer;
MediaPlayer1->FileName=OpenDialog1->FileName;
MediaPlayer1->Open();
Panel2->Caption="Maaf tidak ada gambar";
MediaPlayer1->Display=Panel1;
Panel5->Caption=OpenDialog1->FileName;
RB2->Enabled=True;
RB3->Enabled=True;
RB4->Enabled=True;
RB2->Checked=False;
RB3->Checked=False;
RB4->Checked=False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RBCDClick(TObject *Sender)
{
MediaPlayer1->Close();
BTGanti->Enabled=True;
MediaPlayer1->DeviceType=dtCDAudio;
MediaPlayer1->FileName=EmptyStr;
MediaPlayer1->Open();
Panel2->Caption="Maaf, Tidak ada gambar";
MediaPlayer1->Display=Panel1;
Panel5->Caption="CD Audio";
RB2->Enabled=True;
RB3->Enabled=True;
RB4->Enabled=True;
RB2->Checked=False;
RB3->Checked=False;
RB4->Checked=False;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BTcloseClick(TObject *Sender)
{
Close(); //UNTUK MEMBACA SCRIP CLOSE. SEHINGGA SAAT I KLIK PROGRAM SELESAI
}
//---------------------------------------------------------------------------
UNIT1.H
#include
#include
#include
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TPanel *Panel1;
TPanel *Panel6;
TPanel *Panel3;
TPanel *Panel4;
TPanel *Panel5;
TPanel *Panel2;
TButton *BTGanti;
TButton *BTclose;
TGroupBox *GroupBox1;
TGroupBox *GroupBox2;
TRadioButton *RB2;
TRadioButton *RB3;
TRadioButton *RB4;
TRadioButton *RBAVY;
TRadioButton *RBWAV;
TRadioButton *RBMIDI;
TRadioButton *RBCD;
TMediaPlayer *MediaPlayer1;
TOpenDialog *OpenDialog1;
void __fastcall BTGantiClick(TObject *Sender);
void __fastcall RB2Click(TObject *Sender);
void __fastcall RB3Click(TObject *Sender);
void __fastcall RB4Click(TObject *Sender);
void __fastcall RBAVYClick(TObject *Sender);
void __fastcall RBWAVClick(TObject *Sender);
void __fastcall RBMIDIClick(TObject *Sender);
void __fastcall RBCDClick(TObject *Sender);
void __fastcall BTcloseClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
OUTPUT :
1 komentar:
Wahhhh..... Anak IT ya...
Posting Komentar