int ms = MediaPlayer1->Length;
AnsiString st = IntToStr(SECOND(ms));
if (st.Length() == 1)
st = "0" + st;
st = IntToStr(MINUTE(ms)) + ":" + st;
Label1->Caption = st;
Label3->Caption = "0:00";
// tiklash jarayonini faollashtirish
SpeedButton2->Glyph->Assign(bmPause);
SpeedButton2->Hint = "Pause";
SpeedButton2->Tag = 1;
SpeedButton1->Enabled=false;//Eject tugmasi murojatli
//emas
MediaPlayer1->Play();
Timer1->Enabled = true;
}
// Play/Stop tugmasini bosish (tiklash/to’xtash)
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
if (SpeedButton2->Tag == 0)
{
// Play tugmasini bosish
SpeedButton2->Glyph->Assign(bmPause);
SpeedButton2->Hint = "Pause";
SpeedButton2->Tag = 1;
SpeedButton1->Enabled = false; // Eject tugmasi
// murojaatli emas
MediaPlayer1->Play();
Timer1->Enabled = true;
}
else // Stop tugmasini bosish
{
MediaPlayer1->Stop();
SpeedButton2->Glyph->Assign(bmPlay);
SpeedButton2->Hint = "Play";
SpeedButton2->Tag = 0;
SpeedButton1->Enabled=true;//Eject tugmasi murojaatli
Timer1->Enabled = false;
}
}
// pleyerdan signal
void __fastcall TForm1::MediaPlayer1Notify(TObject *Sender)
{
if ((MediaPlayer1->Mode == mpStopped ) &&
(SpeedButton2->Tag == 1))
{
Timer1->Enabled = false;
SpeedButton2->Glyph->Assign(bmPlay);
SpeedButton2->Hint = "Play";
SpeedButton2->Tag = 0;
SpeedButton1->Enabled = true; // Eject tugmasini
// murojaatli qilish
}
}
/*Pain xodisani qayta ishlash funksiyasi oyna xosil bo’lganda birinchi kadrni tasvirlashni (qayta chizish) ta’minlaydi, masalan,
например, после того,как пользователь отодвинет другое окно, перекрывающее окон Video Player. */
void __fastcall TForm1::FormPaint(TObject *Sender)
{
if (MediaPlayer1->Mode == mpStopped )
{
MediaPlayer1->Position = 1;
MediaPlayer1->Position = 0;
}
}
// dastur ishining tugashi
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
MediaPlayer1->Close();
}
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
// tiklash vaqti xaqida ma’lumotlarni chiqarish
// MediaPlayerl->TimeFormat = tfMilliseconds;
int ms = MediaPlayer1->Position;
AnsiString st = IntToStr(SECOND(ms));
if ( st.Length() == 1)
st = "0" + st;
st = IntToStr(MINUTE(ms)) + ":" + st;
Label3->Caption = st;
}
Animatsiya
Animatsiya dasturi, uning forma va oynasi 1.46-rasmda keltirlgan, Animate komponentasi yordamida AVI-animatsiyalarni tiklashni namoish etadi. Animatsiya dastur ishini boshlagan vaqtda fayldan yuklanadi.
Button1
Animate1
1.46-rasm. Dastur formasi va oynasi
bool loaded = false; // animatsiya yuklangan
// forma konstruktori
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
/* agar animatsiya fayli murojaatli emas yoki animatsiya ovozli bo’lsa, istisni xosil bo’ladi */
try
{
Animate1->FileName = "cool.avi";
}
catch (Exception &e)
{ }
Form1->Caption = "Animatsiya - " + Animate1->FileName;
loaded = true;
Label1->Caption="Kadrlar: "+IntToStr(Animate1->
FrameCount)+" Kadrlar o'lchami: "+IntToStr(
Animate1->Width)+"x" + IntToStr(Animate1->Height);
}
// dastur ishining boshlanishi
void __fastcall TForm1::FormActivate(TObject *Sender)
{
if (loaded)
// birinchidan oxirgi kadr bo’yicha bir marta
//animatsiyani tiklanadi
Animate1->Play(1,Animate1->FrameCount,1);
}
// Play tugmasini bosish
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (loaded)
// birinchidan oxirgi kadr bo’yicha bir marta
//animatsiyani tiklanadi
Animate1->Play(1,Animate1->FrameCount,1);
}
Do'stlaringiz bilan baham: |