summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--Plexservice.cpp8
-rw-r--r--Plexservice.h2
-rw-r--r--hlsPlayerControl.cpp4
-rw-r--r--plex.cpp35
-rw-r--r--plex.h8
6 files changed, 51 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 01c2f33..b902f3a 100644
--- a/Makefile
+++ b/Makefile
@@ -70,7 +70,7 @@ SOFILE = libvdr-$(PLUGIN).so
INCLUDES +=
-DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
+DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DPLUGIN='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
$(if $(GIT_REV), -DGIT_REV='"$(GIT_REV)"')
### Make it standard
diff --git a/Plexservice.cpp b/Plexservice.cpp
index a61caec..d208882 100644
--- a/Plexservice.cpp
+++ b/Plexservice.cpp
@@ -145,11 +145,13 @@ std::shared_ptr<MediaContainer> Plexservice::GetSection(std::string section, boo
}
}
-std::shared_ptr<MediaContainer> Plexservice::GetLastSection()
+std::shared_ptr<MediaContainer> Plexservice::GetLastSection(bool current)
{
if(m_vUriStack.size() > 1) {
- // discard last one
- m_vUriStack.pop();
+ if(!current) {
+ // discard last one
+ m_vUriStack.pop();
+ }
std::string uri = m_vUriStack.top();
return GetSection(uri, false);
}
diff --git a/Plexservice.h b/Plexservice.h
index e2cab4b..4f81caf 100644
--- a/Plexservice.h
+++ b/Plexservice.h
@@ -44,7 +44,7 @@ public:
void DisplaySections();
std::shared_ptr<MediaContainer> GetSection(std::string section, bool putOnStack = true);
- std::shared_ptr<MediaContainer> GetLastSection();
+ std::shared_ptr<MediaContainer> GetLastSection(bool current = false);
void GetAuthDetails();
void Authenticate();
PlexServer* GetServer();
diff --git a/hlsPlayerControl.cpp b/hlsPlayerControl.cpp
index 1f19336..73e2d6f 100644
--- a/hlsPlayerControl.cpp
+++ b/hlsPlayerControl.cpp
@@ -1,7 +1,9 @@
#include "hlsPlayerControl.h"
#include <vdr/status.h>
+#include <vdr/remote.h>
+#include "plex.h"
#include "PlexServer.h"
#include "Plexservice.h"
#include "MediaContainer.h"
@@ -125,6 +127,8 @@ eOSState cHlsPlayerControl::ProcessKey(eKeys Key)
case kBlue:
Hide();
Stop();
+ cMyPlugin::CalledFromCode = true;
+ cRemote::CallPlugin(PLUGIN);
return osEnd;
default: {
DoShowMode = false;
diff --git a/plex.cpp b/plex.cpp
index f9a1a84..89193af 100644
--- a/plex.cpp
+++ b/plex.cpp
@@ -11,16 +11,30 @@
static char ShowBrowser; ///< flag show browser
static std::shared_ptr<plexclient::Plexservice> pPlexService;
+std::shared_ptr<plexclient::Plexservice> cPlexBrowser::pLastService;
+int cPlexBrowser::lastCurrentItem;
+
cPlexBrowser::cPlexBrowser(const char *title, std::shared_ptr<plexclient::Plexservice> Service) :cOsdMenu(title)
{
dsyslog("[plex]%s:\n", __FUNCTION__);
pService = Service;
pService->Authenticate();
- pCont = pService->GetSection(pService->StartUri);
+ if(pService == pLastService) {
+ pCont = pService->GetLastSection(true);
+ }
+ else {
+ pCont = pService->GetSection(pService->StartUri);
+ }
SetMenuCategory(mcRecording);
CreateMenu();
}
+cPlexBrowser* cPlexBrowser::RecoverLastState()
+{
+ cPlexBrowser* pBrowser = new cPlexBrowser("", cPlexBrowser::pLastService);
+ return pBrowser;
+}
+
void cPlexBrowser::CreateMenu()
{
// Clear Menu
@@ -44,10 +58,16 @@ void cPlexBrowser::CreateMenu()
if(Count() < 1) {
Add(new cPlexOsdItem("Empty"));
}
+ else if (pService == pLastService) {
+ // recover last selected item
+ cOsdItem* item = Get(lastCurrentItem);
+ SetCurrent(item);
+ pLastService = NULL;
+ }
+
Display();
}
-
eOSState cPlexBrowser::ProcessKey(eKeys key)
{
eOSState state;
@@ -98,6 +118,8 @@ eOSState cPlexBrowser::ProcessSelected()
if(item->IsVideo()) {
+ pLastService = pService;
+ lastCurrentItem = current;
cMyPlugin::PlayFile(*item->GetAttachedVideo());
return osEnd;
}
@@ -230,6 +252,8 @@ eOSState cPlayMenu::ProcessKey(eKeys key)
// cPlugin
//////////////////////////////////////////////////////////////////////////////
+volatile bool cMyPlugin::CalledFromCode = false;
+
/**
** Initialize any member variables here.
**
@@ -300,7 +324,12 @@ const char *cMyPlugin::MainMenuEntry(void)
cOsdObject *cMyPlugin::MainMenuAction(void)
{
//dsyslog("[plex]%s:\n", __FUNCTION__);
-
+
+ if(CalledFromCode) {
+ CalledFromCode = false;
+ return cPlexBrowser::RecoverLastState();
+ }
+
if (ShowBrowser) {
return new cPlexBrowser("Browse Plex", pPlexService);
}
diff --git a/plex.h b/plex.h
index 89075f5..c2570c8 100644
--- a/plex.h
+++ b/plex.h
@@ -56,10 +56,15 @@ private:
eOSState LevelUp(void);
/// Handle menu item selection
eOSState ProcessSelected();
+
+ static std::shared_ptr<plexclient::Plexservice> pLastService;
+ static int lastCurrentItem;
public:
cPlexBrowser(const char *title, std::shared_ptr<plexclient::Plexservice> Service);
virtual eOSState ProcessKey(eKeys);
+
+ static cPlexBrowser* RecoverLastState();
};
@@ -98,6 +103,9 @@ public:
virtual bool SetupParse(const char *, const char *);
static void PlayFile(plexclient::Video Vid);
+
+public:
+ static volatile bool CalledFromCode;
};