Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

ScreenPlay.h

Go to the documentation of this file.
00001 /***********************************************************************************
00002  *
00003  * Application: Investigator's Dashboard (MultimediaN project 6)
00004  * 
00005  * Screen: Play
00006  *
00007  * Primary author(s): Ork
00008  *                  : 
00009  *                  : 
00010  ***********************************************************************************/
00011 
00012 #ifndef Impala_Application_IDash_ScreenPlay_h
00013 #define Impala_Application_IDash_ScreenPlay_h
00014 
00015 #include "ScreenBase.h"
00016 #include "NfiSixView.h"
00017 #include "OglGui/RadioGroup.h"
00018 
00019 namespace Impala {
00020 namespace Application {
00021 namespace IDash {
00022 
00023 
00024 class ScreenPlay : public ScreenBase,
00025                    public DossierListener, public OglGui::RadioGroupListener
00026 {
00027 
00028 public:
00029 
00030     ScreenPlay(int width, int height) :
00031         ScreenBase(width, height) 
00032     {
00033         InitScreen();
00034     }
00035 
00036     ScreenPlay(OglGui::Window *parent, int width, int height) :
00037         ScreenBase(parent, width, height)
00038     {
00039         InitScreen();
00040     }
00041 
00042     ScreenPlay(OglGui::Window *parent) :
00043         ScreenBase(parent)
00044     {
00045         InitScreen();
00046     }
00047 
00048     virtual void
00049     PlayFileEvent(int videoID)
00050     {
00051 if (videoID != mVideoId)
00052 {
00053     mVideoId = videoID;
00054         ILOG_DEBUG("PlayFileEvent: video ID = " << videoID);
00055         mPlayer->SetVideo(Engine()->ThreadSet()->GetSegmentation()->GetVideoSet(), videoID);
00056         std::ostringstream o;
00057         o << "Video: " << videoID;
00058         mLabel->SetText(o.str());
00059         mHasFile = true;
00060         mPlayer->OpenVideo();
00061 }
00062 Rewind();
00063         Play();
00064     }
00065 
00066     void
00067     Play()
00068     {
00069         ILOG_DEBUG("Playing...");
00070         if (!mHasFile)
00071             return;
00072         mPlayer->Play();
00073     }
00074 
00075     void
00076     Stop()
00077     {
00078         if (!mHasFile)
00079             return;
00080         mPlayer->TogglePause();
00081     }
00082 
00083     void
00084     Rewind()
00085     {
00086         if (!mHasFile)
00087             return;
00088         mPlayer->Rewind();
00089     }
00090 
00091     void
00092     ToBrowser()
00093     {
00094         ILOG_DEBUG("Sending ViewBrowserEvent..");
00095         if (mHasFile)
00096             mPlayer->Stop();
00097         for (int i=0; i<mListeners.size();i++)
00098             mListeners[i]->ViewBrowserEvent();
00099 
00100     }
00101 
00102     // handlers:
00103     virtual void
00104     ButtonSelectionEvent(Button *src, void* vData)
00105     {
00106         int userData = (long long) vData;
00107         switch (userData) {
00108             case BTN_PLAY:
00109                 ILOG_USER("BTN: play");
00110                 Play();
00111             break;
00112             case BTN_STOP:
00113                 ILOG_USER("BTN: stop");
00114                 Stop();
00115             break;
00116             case BTN_REWIND:
00117                 ILOG_USER("BTN: rewind");
00118                 Rewind();
00119             break;
00120             case BTN_TOBROWSER:
00121                 ILOG_USER("BTN: to browser");
00122                 ToBrowser();
00123             break;
00124         }
00125     }
00126 
00127     virtual void
00128     OnRadioChange(RadioGroup *src, int button, void* data)
00129     {
00130         if (data == (void*) RAD_SPEED) {
00131             switch (button) {
00132             case 0: // normal speed
00133                 ILOG_USER("BTN: user selected normal speed.");
00134                 mPlayer->DoNormalSpeed(true);
00135                 break;
00136             case 1: // fast speed
00137                 ILOG_USER("BTN: user selected fast speed.");
00138                 mPlayer->DoNormalSpeed(false);
00139                 break;
00140             }
00141         }
00142 
00143         if (data == (void*) RAD_LOOP) {
00144             switch (button) {
00145             case 0: // normal speed
00146                 ILOG_USER("BTN: user selected loop disabled.");
00147                 mPlayer->SetLoopVideo(false);
00148                 break;
00149             case 1: // fast speed
00150                 ILOG_USER("BTN: user selected loop enabled.");
00151                 mPlayer->SetLoopVideo(true);
00152                 break;
00153             }
00154         }
00155 
00156     }
00157 
00158     // code to handle listeners
00159 
00160     void AddDossierListener(DossierListener *l)
00161     {
00162         mListeners.push_back(l);
00163     }
00164 
00165 private:
00166     void
00167     InitScreen()
00168     {
00169         ILOG_DEBUG("constructing screen Play");
00170 mVideoId = -1;
00171         Window *header = new Window(this, 0, WndHeight() - 100, WndWidth(), 80);
00172         SetAsBox(header);
00173 
00174         new Strut(header, 60, 20);
00175         mLabel = new StaticText(header, 0, 20, WndWidth(), 20, "No video loaded");
00176         header->ScaleChildren();
00177         header->ConnectTo(this, L2L|R2R|T2T|B2T);
00178 
00179         Window *footer = new Window(this, 0, 0, WndWidth(), 80);
00180         new Strut(footer, 4000, 20);
00181         new Strut(footer, 40, 20);
00182         Button *play = new Button(footer, 60, 40, ">");
00183         Button *stop = new Button(footer, 40, 40, "||");
00184         Button *rewind = new Button(footer, 40, 40, "<<");
00185         new Strut(footer, 100, 20);
00186         mHasFile = false;
00187         play->SetButtonListener(this, BTN_PLAY);
00188         stop->SetButtonListener(this, BTN_STOP);
00189         rewind->SetButtonListener(this, BTN_REWIND);
00190 
00191         Button *backtobrowser = new Button(footer, 200, 40, "back to browser");
00192         backtobrowser->SetButtonListener(this, BTN_TOBROWSER);
00193 
00194 
00195         RadioGroup *speed = new RadioGroup(footer, 292, 40);
00196         speed->SetButtonDimensions(140, 40);
00197         speed->Add("Normal speed", BEV_RAISED, true);
00198         speed->Add("Fast speed", BEV_RAISED, true);
00199         speed->SetRadioListener(this, RAD_SPEED);
00200 
00201         RadioGroup *loop = new RadioGroup(footer, 292, 40);
00202         loop->SetButtonDimensions(140, 40);
00203         loop->Add("Play once", BEV_RAISED, true);
00204         loop->Add("Loop video", BEV_RAISED, true);
00205         loop->SetRadioListener(this, RAD_LOOP);
00206 
00207         footer->RepositionViewports();
00208         footer->ScaleChildren();
00209         footer->ConnectTo(this, L2L|R2R|T2B|B2B);
00210         SetAsBox(footer);
00211 
00212         //start sixvid window
00213         mPlayer = new NfiSixView(this, 0, 80, WndWidth(), WndHeight() - 180);
00214         mPlayer->SetLoopVideo(false);
00215         mPlayer->ConnectTo(this);
00216         SetAsBox(mPlayer);
00217         if (!mPlayer->Valid())
00218         {
00219             ILOG_ERROR("NfiVideoDemo failed\n");
00220             return;
00221         }
00222     }
00223 
00224     NfiSixView *mPlayer;
00225     StaticText *mLabel;
00226     bool mHasFile;
00227 int mVideoId;
00228 
00229     const static int BTN_PLAY = 1;
00230     const static int BTN_STOP = 2;
00231     const static int BTN_REWIND = 3;
00232     const static int BTN_TOBROWSER = 4;
00233 
00234     const static int RAD_SPEED = 1;
00235     const static int RAD_LOOP  = 2;
00236 
00237     std::vector<DossierListener*> mListeners;
00238 
00239     ILOG_VAR_DEC;
00240 };
00241 
00242 ILOG_VAR_INIT(ScreenPlay, Application.IDash);
00243 
00244 
00245 
00246 
00247 
00248 
00249 }
00250 }
00251 }
00252 
00253 #endif

Generated on Fri Mar 19 09:30:27 2010 for ImpalaSrc by  doxygen 1.5.1