]> git.vomp.tv Git - vompclient.git/blob - vvideolive.cc
Options view files added, new remote type supported
[vompclient.git] / vvideolive.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "vvideolive.h"
22
23 VVideoLive::VVideoLive(List* tchanList)
24 {
25   player = new Player(NULL);
26   player->init();
27   vdr = VDR::getInstance();
28   chanList = tchanList;
29   currentChannel = 0;
30
31   Video* video = Video::getInstance();
32   setDimensions(video->getScreenHeight(), video->getScreenWidth());
33   Colour transparent(0, 0, 0, 0);
34   setBackgroundColour(transparent);
35 }
36
37 VVideoLive::~VVideoLive()
38 {
39   delete player;
40 }
41
42 void VVideoLive::draw()
43 {
44   View::draw();
45 }
46
47 int VVideoLive::handleCommand(int command)
48 {
49   switch(command)
50   {
51     case Remote::PLAY:
52     {
53       player->play(); // do resync
54       return 2;
55     }
56
57     case Remote::STOP:
58     case Remote::BACK:
59     case Remote::MENU:
60     {
61       player->stop();
62       vdr->stopStreaming();
63       return 4;
64     }
65     case Remote::DF_UP:
66     case Remote::UP:
67     {
68       player->stop();
69       vdr->stopStreaming();
70       upChannel();
71       doBanner();
72       vdr->streamChannel(currentChannel);
73       player->play();
74       return 2;
75     }
76     case Remote::DF_DOWN:
77     case Remote::DOWN:
78     {
79       player->stop();
80       vdr->stopStreaming();
81       downChannel();
82       doBanner();
83       vdr->streamChannel(currentChannel);
84       player->play();
85       return 2;
86     }
87     case Remote::OK:
88     {
89       doBanner();
90       return 2;
91     }
92
93     case Remote::ZERO ... Remote::NINE:
94     {
95       VChannelSelect* v = new VChannelSelect(this, command);
96       ViewMan::getInstance()->addNoLock(v);
97 //      ViewMan::getInstance()->timedDelete(v, 4, 0);
98       v->draw();
99       v->show();
100     }
101   }
102
103   return 1;
104 }
105
106 void VVideoLive::processMessage(Message* m)
107 {
108   if (m->message == Message::CHANNEL_CHANGE)
109   {
110     // check channel number is valid
111     Channel* channel;
112     for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
113     {
114       if (channel->number == m->parameter)
115       {
116         player->stop();
117         vdr->stopStreaming();
118         setChannel(channel->number);
119       }
120     }
121   }
122 }
123
124 void VVideoLive::doBanner()
125 {
126   VLiveBanner* v = new VLiveBanner();
127   ViewMan::getInstance()->addNoLock(v);
128   ViewMan::getInstance()->timedDelete(v, 4, 0);
129   v->draw();
130   v->show();
131 }
132
133 void VVideoLive::setChannel(int number)
134 {
135   currentChannel = number;
136 //  doBanner();
137   vdr->streamChannel(currentChannel);
138   player->play();
139 }
140
141 void VVideoLive::upChannel()
142 {
143   Channel* channel;
144   for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
145   {
146     if (channel->number == currentChannel)
147     {
148       chanList->next();
149       channel = (Channel*)chanList->getCurrent();
150       if (!channel) return;
151       currentChannel = channel->number;
152     }
153   }
154 }
155
156 void VVideoLive::downChannel()
157 {
158   Channel* channel;
159   Channel* prevChannel = NULL;
160   for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
161   {
162     if (channel->number == currentChannel)
163     {
164       if (!prevChannel) return;
165       currentChannel = prevChannel->number;
166     }
167     prevChannel = channel;
168   }
169 }