//---------------------------------------------------------------------------

#include <vcl.h>
#include "ITSLangTransF.h"
#pragma hdrstop

#include "FrmFullScreenF.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "FFBaseComponent"
#pragma link "FFBasePlay"
#pragma link "FFPlay"
#pragma resource "*.dfm"
TFrmFullScreen *FrmFullScreen = NULL;
//---------------------------------------------------------------------------
__fastcall TFrmFullScreen::TFrmFullScreen(TComponent* Owner)
    : TForm(Owner)
{
    //LangTrans->Translate(this, ITSDb_GetConnection());

    this->Color = clBlack;
    PnlStream->ParentColor = false;
    PnlStream->Color = clBlack;
}
//---------------------------------------------------------------------------
void __fastcall TFrmFullScreen::PnlStreamDblClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------
void __fastcall TFrmFullScreen::FormClose(TObject *Sender, TCloseAction &Action)
{
    Disconnect();

    FrmFullScreen = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TFrmFullScreen::FormDblClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

void __fastcall TFrmFullScreen::FormShow(TObject *Sender)
{
    this->Color = clBlack;
    PnlStream->ParentColor = false;
    PnlStream->Color = clBlack;

    Connect();
}
//---------------------------------------------------------------------------

void __fastcall TFrmFullScreen::Connect()
{
    Disconnect();

    PnlStream->Caption = "Connecting...";//¿¬°áÁß...";

    try
    {
        FFPlayer1->TryOpen(STRM_ADDR, PnlStream->Handle);
        FConHandle = (long)FFPlayer1->ScreenHandle;
Application->ProcessMessages();
    }
    catch(Exception &e)
    {
    }
    FPlay = true;
}
//---------------------------------------------------------------------------

void __fastcall TFrmFullScreen::Disconnect()
{
    if (!FPlay) return;

    FPlay = false;
    PnlStream->Caption = "Disconnect";
    try
    {
        if (FFPlayer1->ScreenHandle != NULL)
        {
            FFPlayer1->Stop(true);
            PostMessage(FFPlayer1->ScreenHandle, CM_INVALIDATE, 0, 0);
            UpdateWindow(FFPlayer1->ScreenHandle);
        }
Application->ProcessMessages();
        FConHandle = 0;
    }
    catch(Exception &e)
    {
    }

    PnlStream->Caption = "Disconnected";
    FConHandle = 0;
    FPlay = false;
}
//---------------------------------------------------------------------------

void __fastcall TFrmFullScreen::TmrCloseTimer(TObject *Sender)
{
    TmrClose->Enabled = false;
    Close();
}
//---------------------------------------------------------------------------

