FrmCameraFullScreenF.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "FrmCameraFullScreenF.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "PasLibVlcPlayerUnit"
  8. #pragma resource "*.dfm"
  9. TFrmCameraFullScreen *FrmCameraFullScreen = NULL;
  10. //---------------------------------------------------------------------------
  11. __fastcall TFrmCameraFullScreen::TFrmCameraFullScreen(TComponent* Owner)
  12. : TForm(Owner)
  13. {
  14. this->Color = clBlack;
  15. PnlStream->ParentColor = false;
  16. PnlStream->Color = clBlack;
  17. }
  18. //---------------------------------------------------------------------------
  19. void __fastcall TFrmCameraFullScreen::PnlStreamDblClick(TObject *Sender)
  20. {
  21. Close();
  22. }
  23. //---------------------------------------------------------------------------
  24. void __fastcall TFrmCameraFullScreen::FormClose(TObject *Sender, TCloseAction &Action)
  25. {
  26. Disconnect();
  27. FrmCameraFullScreen = NULL;
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall TFrmCameraFullScreen::FormDblClick(TObject *Sender)
  31. {
  32. Close();
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TFrmCameraFullScreen::FormShow(TObject *Sender)
  36. {
  37. Refresh();
  38. Application->ProcessMessages();
  39. this->Color = clBlack;
  40. PnlStream->ParentColor = false;
  41. PnlStream->Color = clBlack;
  42. Connect();
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TFrmCameraFullScreen::AdjustVideoFit()
  46. {
  47. try {
  48. if (FConHandle > 0) {
  49. String ratioData = IntToStr(PasLibVlcPlayer1->Width) + ":" + IntToStr(PasLibVlcPlayer1->Height);
  50. PasLibVlcPlayer1->SetVideoAspectRatio(ratioData);
  51. }
  52. }
  53. catch(Exception &e) {
  54. }
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TFrmCameraFullScreen::Connect()
  58. {
  59. Disconnect();
  60. PnlStream->Caption = "--- 영상 연결 중 ---";
  61. try
  62. {
  63. PasLibVlcPlayer1->Play(RTSP_ADDR);
  64. FConHandle = 1;
  65. Application->ProcessMessages();
  66. AdjustVideoFit();
  67. Application->ProcessMessages();
  68. }
  69. catch(Exception &e)
  70. {
  71. }
  72. FPlay = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TFrmCameraFullScreen::Disconnect()
  76. {
  77. if (!FPlay) return;
  78. FPlay = false;
  79. PnlStream->Caption = "--- 영상 연결 해제 ---";
  80. try
  81. {
  82. if (FConHandle > 0)
  83. {
  84. PasLibVlcPlayer1->Stop();
  85. }
  86. Application->ProcessMessages();
  87. FConHandle = 0;
  88. }
  89. catch(Exception &e)
  90. {
  91. }
  92. PnlStream->Caption = "*** 영상 연결 종료 ***";
  93. FConHandle = 0;
  94. FPlay = false;
  95. }
  96. //---------------------------------------------------------------------------
  97. void __fastcall TFrmCameraFullScreen::TmrCloseTimer(TObject *Sender)
  98. {
  99. TmrClose->Enabled = false;
  100. Close();
  101. }
  102. //---------------------------------------------------------------------------
  103. void __fastcall TFrmCameraFullScreen::PasLibVlcPlayer1DblClick(TObject *Sender)
  104. {
  105. Close();
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TFrmCameraFullScreen::PasLibVlcPlayer1MediaPlayerPlaying(TObject *Sender)
  109. {
  110. AdjustVideoFit();
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TFrmCameraFullScreen::PasLibVlcPlayer1MediaPlayerPositionChanged(TObject *Sender, float position)
  114. {
  115. if (PasLibVlcPlayer1->Visible == false) {
  116. PasLibVlcPlayer1->Visible = true;
  117. PnlStream->Refresh();
  118. AdjustVideoFit();
  119. }
  120. }
  121. //---------------------------------------------------------------------------
  122. void __fastcall TFrmCameraFullScreen::FormKeyPress(TObject *Sender, wchar_t &Key)
  123. {
  124. Close();
  125. }
  126. //---------------------------------------------------------------------------