1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
#include "hlsPlayerControl.h"
#include <vdr/status.h>
#include "PlexServer.h"
#include "Plexservice.h"
// static
cControl* cHlsPlayerControl::Create(plexclient::Video* Video)
{
if(!Video->m_pServer)
return NULL;
std::string transcodeUri = plexclient::Plexservice::GetUniversalTranscodeUrl(Video);
cHlsPlayerControl* playerControl = new cHlsPlayerControl(new cHlsPlayer(transcodeUri, Video), Video);
playerControl->m_title = Video->m_sTitle;
return playerControl;
}
cHlsPlayerControl::cHlsPlayerControl(cHlsPlayer* Player, plexclient::Video* Video) :cControl(Player)
{
player = Player;
m_pVideo = Video;
//m_title = title;
displayReplay = NULL;
visible = modeOnly = shown = false;
lastCurrent = lastTotal = -1;
lastPlay = lastForward = false;
lastSpeed = -2; // an invalid value
timeoutShow = 0;
cStatus::MsgReplaying(this, m_title.c_str(), Video->m_pMedia->m_sPartFile.c_str(), true);
}
cHlsPlayerControl::~cHlsPlayerControl()
{
}
cString cHlsPlayerControl::GetHeader(void)
{
return m_title.c_str();
}
void cHlsPlayerControl::Hide(void)
{
if (visible) {
delete displayReplay;
displayReplay = NULL;
SetNeedsFastResponse(false);
visible = false;
modeOnly = false;
lastPlay = lastForward = false;
lastSpeed = -2; // an invalid value
//timeSearchActive = false;
timeoutShow = 0;
}
}
void cHlsPlayerControl::Show(void)
{
ShowTimed();
}
eOSState cHlsPlayerControl::ProcessKey(eKeys Key)
{
if (!Active())
return osEnd;
if (Key == kPlayPause) {
bool Play, Forward;
int Speed;
GetReplayMode(Play, Forward, Speed);
if (Speed >= 0)
Key = Play ? kPlay : kPause;
else
Key = Play ? kPause : kPlay;
}
if (visible) {
if (timeoutShow && time(NULL) > timeoutShow) {
Hide();
ShowMode();
timeoutShow = 0;
} else if (modeOnly)
ShowMode();
else
shown = ShowProgress(!shown) || shown;
}
bool DoShowMode = true;
switch (int(Key)) {
// Positioning:
case kPlay:
case kUp:
Play();
break;
case kPause:
case kDown:
Pause();
break;
case kFastRew|k_Release:
case kLeft|k_Release:
//if (Setup.MultiSpeedMode) break;
case kFastRew:
case kLeft:
//Backward();
break;
case kFastFwd|k_Release:
case kRight|k_Release:
//if (Setup.MultiSpeedMode) break;
case kFastFwd:
case kRight:
//Forward();
break;
case kRed:
//TimeSearch();
break;
case kGreen|k_Repeat:
case kGreen:
Hide();
player->JumpRelative(-600);
break;
case kYellow|k_Repeat:
case kYellow:
Hide();
player->JumpRelative(600);
break;
case kStop:
case kBlue:
Hide();
Stop();
return osEnd;
default: {
DoShowMode = false;
switch (int(Key)) {
default: {
switch (Key) {
case kOk:
if (visible && !modeOnly) {
Hide();
DoShowMode = true;
} else
Show();
break;
case kBack:
Hide();
//menu = new cTitleMenu(this);
break;
default:
return osUnknown;
}
}
}
}
if (DoShowMode)
ShowMode();
}
return osContinue;
}
bool cHlsPlayerControl::Active(void)
{
return player && player->Active();
}
void cHlsPlayerControl::Pause(void)
{
if(player)
player->Pause();
}
void cHlsPlayerControl::Play(void)
{
if(player)
player->Play();
}
void cHlsPlayerControl::Stop(void)
{
if(player)
player->Stop();
}
void cHlsPlayerControl::ShowMode(void)
{
//dsyslog("[plex]: '%s'\n", __FUNCTION__);
if (visible || Setup.ShowReplayMode && !cOsd::IsOpen()) {
bool Play, Forward;
int Speed;
if (GetReplayMode(Play, Forward, Speed) && (!visible || Play != lastPlay || Forward != lastForward || Speed != lastSpeed)) {
bool NormalPlay = (Play && Speed == -1);
if (!visible) {
if (NormalPlay)
return; // no need to do indicate ">" unless there was a different mode displayed before
visible = modeOnly = true;
displayReplay = Skins.Current()->DisplayReplay(modeOnly);
}
if (modeOnly && !timeoutShow && NormalPlay)
timeoutShow = time(NULL) + 3;
displayReplay->SetMode(Play, Forward, Speed);
lastPlay = Play;
lastForward = Forward;
lastSpeed = Speed;
}
}
}
bool cHlsPlayerControl::ShowProgress(bool Initial)
{
int Current, Total;
if (GetIndex(Current, Total) && Total > 0) {
if (!visible) {
displayReplay = Skins.Current()->DisplayReplay(modeOnly);
//displayReplay->SetMarks(player->Marks());
SetNeedsFastResponse(true);
visible = true;
}
if (Initial) {
lastCurrent = lastTotal = -1;
}
if (Current != lastCurrent || Total != lastTotal) {
if (Total != lastTotal) {
int Index = Total;
displayReplay->SetTotal(IndexToHMSF(Index, false, FramesPerSecond()));
if (!Initial)
displayReplay->Flush();
}
displayReplay->SetProgress(Current, Total);
if (!Initial)
displayReplay->Flush();
displayReplay->SetCurrent(IndexToHMSF(Current, false, FramesPerSecond()));
cString Title;
//cString Pos = player ? player->PosStr() : cString(NULL);
//if (*Pos && strlen(Pos) > 1) {
// Title = cString::sprintf("%s (%s)", m_title.c_str(), *Pos);
//} else {
Title = m_title.c_str();
//}
displayReplay->SetTitle(Title);
displayReplay->Flush();
lastCurrent = Current;
}
lastTotal = Total;
ShowMode();
return true;
}
return false;
}
void cHlsPlayerControl::ShowTimed(int Seconds)
{
if (modeOnly)
Hide();
if (!visible) {
shown = ShowProgress(true);
timeoutShow = (shown && Seconds > 0) ? time(NULL) + Seconds : 0;
} else if (timeoutShow && Seconds > 0)
timeoutShow = time(NULL) + Seconds;
}
|