blob: 1c25feda184e3687ce600c166b081ab82f1b8128 (
plain)
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
|
#include "plexSdOsd.h"
#include "viewGridNavigator.h"
#include "pictureCache.h"
#include <vdr/thread.h>
#include "SubscriptionManager.h"
#include "plex.h"
cMutex cPlexSdOsd::RedrawMutex;
cPlexSdOsd::cPlexSdOsd()
{
m_pRootView = NULL;
}
cPlexSdOsd::~cPlexSdOsd()
{
if(m_pBrowserGrid)
m_pBrowserGrid->Clear();
if(m_pMessage)
m_pMessage->Clear();
cPictureCache::GetInstance().RemoveAll();
delete m_pRootView;
}
bool cPlexSdOsd::SdSupport()
{
bool skinDesignerAvailable = InitSkindesignerInterface("plex");
if (skinDesignerAvailable) {
skindesignerapi::cOsdView *rootView = GetOsdView(eViews::viRootView);
if (!rootView) {
esyslog("[plex]: used skindesigner skin does not support plex");
return false;
}
}
return skinDesignerAvailable;
}
void cPlexSdOsd::Show(void)
{
bool skinDesignerAvailable = InitSkindesignerInterface("plex");
if (!skinDesignerAvailable) {
return;
}
m_pRootView = GetOsdView(eViews::viRootView);
if (!m_pRootView) {
esyslog("[plex]: used skindesigner skin does not support plex");
return;
}
m_pBrowserGrid = std::shared_ptr<cBrowserGrid>(new cBrowserGrid(m_pRootView));
m_pMessage = std::shared_ptr<skindesignerapi::cViewElement>(m_pRootView->GetViewElement(eViewElementsRoot::verMessage));
m_messageDisplayed = false;
Flush();
}
void cPlexSdOsd::Flush()
{
m_pBrowserGrid->DrawGrid();
m_pBrowserGrid->Flush();
}
eOSState cPlexSdOsd::ProcessKey(eKeys Key)
{
eOSState state = eOSState::osContinue;
plexclient::Video* vid = NULL;
if (m_pBrowserGrid->DrawTime())
m_pBrowserGrid->Flush();
//check if some plexservers are online
if(plexclient::plexgdm::GetInstance().GetFirstServer() == NULL ||
(plexclient::plexgdm::GetInstance().GetFirstServer() && plexclient::plexgdm::GetInstance().GetFirstServer()->Offline)
) {
DrawMessage(std::string(tr("No Plex Media Server found.")));
switch (Key & ~k_Repeat) {
case kOk:
case kBack:
return eOSState::osEnd;
break;
default:
return eOSState::osContinue;
}
}
if(m_messageDisplayed) {
vid = dynamic_cast<plexclient::Video*>(m_pBrowserGrid->SelectedObject());
switch (Key & ~k_Repeat) {
case kOk:
vid->m_iMyPlayOffset = vid->m_lViewoffset/1000;
m_messageDisplayed = false;
state = eOSState::osUser1;
break;
case kBack:
vid->m_lViewoffset = 0;
state = eOSState::osUser1;
default:
break;
}
} else {
switch (Key & ~k_Repeat) {
case kUp:
if(m_pBrowserGrid->NavigateUp()) Flush();
break;
case kDown:
if(m_pBrowserGrid->NavigateDown()) Flush();
break;
case kLeft:
if(m_pBrowserGrid->NavigateLeft()) Flush();
break;
case kRight:
if(m_pBrowserGrid->NavigateRight()) Flush();
break;
case kOk:
// Play movie or change dir
state = m_pBrowserGrid->NavigateSelect();
Flush();
break;
case kBack:
state = m_pBrowserGrid->NavigateBack();
Flush();
break;
case kBlue:
m_pBrowserGrid->NextViewMode();
Flush();
break;
case kRed:
vid = dynamic_cast<plexclient::Video*>(m_pBrowserGrid->SelectedObject());
if(vid) {
if(vid->m_iViewCount > 0) vid->SetUnwatched();
else vid->SetWatched();
vid->UpdateFromServer();
Flush();
}
break;
case kGreen:
m_pBrowserGrid->PrevTab();
Flush();
break;
case kYellow:
m_pBrowserGrid->NextTab();
Flush();
break;
default:
break;
}
}
if(state == eOSState::osUser1) {
vid = dynamic_cast<plexclient::Video*>(m_pBrowserGrid->SelectedObject());
if(vid->m_iMyPlayOffset == 0 && vid->m_lViewoffset > 0 ) {
cString message = cString::sprintf(tr("'Ok' to start from %ld minutes, 'Back' to start from beginning."), vid->m_lViewoffset / 60000);
DrawMessage(std::string(message));
m_messageDisplayed = true;
} else {
cMyPlugin::PlayFile(*vid);
state = eOSState::osEnd;
}
}
return state;
}
void cPlexSdOsd::DrawMessage(std::string message)
{
m_pMessage->ClearTokens();
m_pMessage->AddStringToken("message", message);
m_pMessage->AddIntToken("displaymessage", true);
m_pMessage->Display();
m_pRootView->Display();
}
|