123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "FrmCameraFullScreenF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "PasLibVlcPlayerUnit"
- #pragma resource "*.dfm"
- TFrmCameraFullScreen *FrmCameraFullScreen = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmCameraFullScreen::TFrmCameraFullScreen(TComponent* Owner)
- : TForm(Owner)
- {
- this->Color = clBlack;
- PnlStream->ParentColor = false;
- PnlStream->Color = clBlack;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::PnlStreamDblClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::FormClose(TObject *Sender, TCloseAction &Action)
- {
- Disconnect();
- FrmCameraFullScreen = NULL;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::FormDblClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::FormShow(TObject *Sender)
- {
- Refresh();
- Application->ProcessMessages();
- this->Color = clBlack;
- PnlStream->ParentColor = false;
- PnlStream->Color = clBlack;
- Connect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::AdjustVideoFit()
- {
- try {
- if (FConHandle > 0) {
- String ratioData = IntToStr(PasLibVlcPlayer1->Width) + ":" + IntToStr(PasLibVlcPlayer1->Height);
- PasLibVlcPlayer1->SetVideoAspectRatio(ratioData);
- }
- }
- catch(Exception &e) {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::Connect()
- {
- Disconnect();
- PnlStream->Caption = "--- 영상 연결 중 ---";
- try
- {
- PasLibVlcPlayer1->Play(RTSP_ADDR);
- FConHandle = 1;
- Application->ProcessMessages();
- AdjustVideoFit();
- Application->ProcessMessages();
- }
- catch(Exception &e)
- {
- }
- FPlay = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::Disconnect()
- {
- if (!FPlay) return;
- FPlay = false;
- PnlStream->Caption = "--- 영상 연결 해제 ---";
- try
- {
- if (FConHandle > 0)
- {
- PasLibVlcPlayer1->Stop();
- }
- Application->ProcessMessages();
- FConHandle = 0;
- }
- catch(Exception &e)
- {
- }
- PnlStream->Caption = "*** 영상 연결 종료 ***";
- FConHandle = 0;
- FPlay = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::TmrCloseTimer(TObject *Sender)
- {
- TmrClose->Enabled = false;
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::PasLibVlcPlayer1DblClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::PasLibVlcPlayer1MediaPlayerPlaying(TObject *Sender)
- {
- AdjustVideoFit();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::PasLibVlcPlayer1MediaPlayerPositionChanged(TObject *Sender, float position)
- {
- if (PasLibVlcPlayer1->Visible == false) {
- PasLibVlcPlayer1->Visible = true;
- PnlStream->Refresh();
- AdjustVideoFit();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraFullScreen::FormKeyPress(TObject *Sender, wchar_t &Key)
- {
- Close();
- }
- //---------------------------------------------------------------------------
|