]> git.vomp.tv Git - vompclient.git/blob - vradiolive.cc
Options view files added, new remote type supported
[vompclient.git] / vradiolive.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 "vradiolive.h"
22
23 VRadioLive::VRadioLive(List* tchanList)
24 {
25   player = new PlayerRadio();
26   player->init();
27   vdr = VDR::getInstance();
28   chanList = tchanList;
29   currentChannel = 0;
30
31   setDimensions(100, 100);
32   setBackgroundColour(Colour::VIEWBACKGROUND);
33 }
34
35 VRadioLive::~VRadioLive()
36 {
37   delete player;
38 }
39
40 void VRadioLive::draw()
41 {
42   View::draw();
43 }
44
45 int VRadioLive::handleCommand(int command)
46 {
47   switch(command)
48   {
49     case Remote::STOP:
50     case Remote::BACK:
51     case Remote::MENU:
52     {
53       player->stop();
54       vdr->stopStreaming();
55       return 4;
56     }
57     case Remote::DF_UP:
58     case Remote::UP:
59     {
60       player->stop();
61       vdr->stopStreaming();
62       upChannel();
63       vdr->streamChannel(currentChannel);
64       player->play();
65       return 2;
66     }
67     case Remote::DF_DOWN:
68     case Remote::DOWN:
69     {
70       player->stop();
71       vdr->stopStreaming();
72       downChannel();
73       vdr->streamChannel(currentChannel);
74       player->play();
75       return 2;
76     }
77   }
78
79   return 1;
80 }
81
82 void VRadioLive::setChannel(int number)
83 {
84   currentChannel = number;
85   vdr->streamChannel(currentChannel);
86   player->play();
87 }
88
89 void VRadioLive::upChannel()
90 {
91   Channel* channel;
92   for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
93   {
94     if (channel->number == currentChannel)
95     {
96       chanList->next();
97       channel = (Channel*)chanList->getCurrent();
98       if (!channel) return;
99       currentChannel = channel->number;
100     }
101   }
102 }
103
104 void VRadioLive::downChannel()
105 {
106   Channel* channel;
107   Channel* prevChannel = NULL;
108   for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next())
109   {
110     if (channel->number == currentChannel)
111     {
112       if (!prevChannel) return;
113       currentChannel = prevChannel->number;
114     }
115     prevChannel = channel;
116   }
117 }