]> git.vomp.tv Git - vompclient-marten.git/blob - vvideorec.cc
Fix for cant power down if server unavailable
[vompclient-marten.git] / vvideorec.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 "vvideorec.h"
22
23 VVideoRec::VVideoRec(Recording* rec)
24 {
25   player = new Player(Command::getInstance());
26   player->init();
27   vdr = VDR::getInstance();
28
29   myRec = rec;
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 VVideoRec::~VVideoRec()
38 {
39   delete player;
40 }
41
42 void VVideoRec::draw()
43 {
44   View::draw();
45 }
46
47 void VVideoRec::go(ULLONG startPosition)
48 {
49   ULLONG recLength = vdr->streamRecording(myRec);
50
51   player->setLength(recLength);
52   player->setPosition(startPosition);
53   player->play();
54 }
55
56 int VVideoRec::handleCommand(int command)
57 {
58   switch(command)
59   {
60     case Remote::PLAY:
61     {
62       player->play(); // do resync
63       return 2;
64     }
65
66     case Remote::STOP:
67     case Remote::BACK:
68     case Remote::MENU:
69     {
70       player->stop();
71       vdr->stopStreaming();
72       return 4;
73     }
74     case Remote::PAUSE:
75     {
76       player->togglePause();
77       return 2;
78     }
79     case Remote::SKIPFORWARD:
80     {
81       player->skipForward(60);
82       return 2;
83     }
84     case Remote::SKIPBACK:
85     {
86       player->skipBackward(60);
87       return 2;
88     }
89     case Remote::FORWARD:
90     {
91       player->toggleFastForward();
92       return 2;
93     }
94     case Remote::YELLOW:
95     {
96       player->skipBackward(10);
97       return 2;
98     }
99     case Remote::BLUE:
100     {
101       player->skipForward(10);
102       return 2;
103     }
104 //    case Remote::REVERSE:
105 //    {
106 //      player->toggleFastBackward();
107 //      return 2;
108 //    }
109
110     case Remote::RED:
111     {
112       player->test();
113       return 2;
114     }
115
116     case Remote::ZERO: player->jumpToPercent(0); return 2;
117     case Remote::ONE: player->jumpToPercent(10); return 2;
118     case Remote::TWO: player->jumpToPercent(20); return 2;
119     case Remote::THREE: player->jumpToPercent(30); return 2;
120     case Remote::FOUR: player->jumpToPercent(40); return 2;
121     case Remote::FIVE: player->jumpToPercent(50); return 2;
122     case Remote::SIX: player->jumpToPercent(60); return 2;
123     case Remote::SEVEN: player->jumpToPercent(70); return 2;
124     case Remote::EIGHT: player->jumpToPercent(80); return 2;
125     case Remote::NINE: player->jumpToPercent(90); return 2;
126
127   }
128
129   return 1;
130 }