diff options
author | chriszero <zerov83@gmail.com> | 2015-04-06 21:40:35 +0200 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2015-04-06 21:40:35 +0200 |
commit | 376c9f258eba669892c2ab00a0863a195ff9d5e8 (patch) | |
tree | 0f9e2593279d6ff03e8d272b91e7980afb4a2850 | |
parent | 13605a7c30e5e35f33ba824c92d2e7cf706a0fa9 (diff) | |
download | vdr-plugin-plex-376c9f258eba669892c2ab00a0863a195ff9d5e8.tar.gz vdr-plugin-plex-376c9f258eba669892c2ab00a0863a195ff9d5e8.tar.bz2 |
Skindesigner
-rw-r--r-- | Directory.cpp | 44 | ||||
-rw-r--r-- | Directory.h | 3 | ||||
-rw-r--r-- | MediaContainer.cpp | 1 | ||||
-rw-r--r-- | MediaContainer.h | 1 | ||||
-rw-r--r-- | PVideo.cpp | 30 | ||||
-rw-r--r-- | browserGrid.cpp | 19 | ||||
-rw-r--r-- | browserGrid.h | 3 | ||||
-rw-r--r-- | plex.cpp | 30 | ||||
-rw-r--r-- | plex.h | 1 | ||||
-rw-r--r-- | plexSdOsd.cpp | 17 | ||||
-rw-r--r-- | plexSdOsd.h | 3 | ||||
-rw-r--r-- | skins/blackhole/xmlfiles/plug-plex-root.xml | 10 |
12 files changed, 137 insertions, 25 deletions
diff --git a/Directory.cpp b/Directory.cpp index e62714f..a598a8f 100644 --- a/Directory.cpp +++ b/Directory.cpp @@ -1,12 +1,14 @@ #include "Directory.h" #include <vdr/i18n.h> #include <Poco/Format.h> +#include "pictureCache.h" namespace plexclient { Directory::Directory(Poco::XML::Node* pNode, PlexServer* Server, MediaContainer* parent) { + m_pParent = parent; m_pServer = Server; if(Poco::icompare(pNode->nodeName(), "Directory") == 0) { Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pNode->attributes(); @@ -46,6 +48,48 @@ void Directory::AddTokens(std::shared_ptr<cOsdElement> grid, bool clear, std::fu { if(clear) grid->ClearTokens(); grid->AddStringToken("title", m_sTitle); + + // Thumb, Cover, Episodepicture + bool cached = false; + std::string thumb = cPictureCache::GetInstance().GetPath(ThumbUri(), Config::GetInstance().ThumbWidth(), Config::GetInstance().ThumbHeight(), cached, OnCached, this); + grid->AddIntToken("hasthumb", cached); + if (cached) grid->AddStringToken("thumb", thumb); + + // Fanart + cached = false; + std::string art = cPictureCache::GetInstance().GetPath(ArtUri(), Config::GetInstance().ArtWidth(), Config::GetInstance().ArtHeight(), cached); + grid->AddIntToken("hasart", cached); + if (cached) grid->AddStringToken("art", art); + + if(m_eType == MediaType::SHOW) { + grid->AddIntToken("isshow", true); + } + + if(m_eType == MediaType::SEASON) { + grid->AddIntToken("isseason", true); + } + + // Banner, Seriesbanner + if(m_pParent && !m_pParent->m_sBanner.empty()) { + cached = false; + std::string banner = cPictureCache::GetInstance().GetPath(m_pServer->GetUri() + m_pParent->m_sBanner, Config::GetInstance().BannerWidth(), Config::GetInstance().BannerHeight(), cached, OnCached, this); + if(cached) { + grid->AddIntToken("hasbanner", true); + grid->AddStringToken("banner", banner); + } + } +} + +std::string Directory::ArtUri() +{ + if(m_sArt.find("http://") != std::string::npos) return m_sArt; + return m_pServer->GetUri() + m_sArt; +} + +std::string Directory::ThumbUri() +{ + if(m_sThumb.find("http://") != std::string::npos) return m_sThumb; + return m_pServer->GetUri() + m_sThumb; } } diff --git a/Directory.h b/Directory.h index f25de85..e97b241 100644 --- a/Directory.h +++ b/Directory.h @@ -53,8 +53,11 @@ public: std::string m_sKey; MediaType m_eType; PlexServer* m_pServer; + MediaContainer* m_pParent; virtual std::string GetTitle(); + std::string ArtUri(); + std::string ThumbUri(); // gridElement virtual void AddTokens(std::shared_ptr<cOsdElement> grid, bool clear = true, std::function<void(cGridElement*)> OnCached = NULL); }; diff --git a/MediaContainer.cpp b/MediaContainer.cpp index c902be2..959c537 100644 --- a/MediaContainer.cpp +++ b/MediaContainer.cpp @@ -20,6 +20,7 @@ MediaContainer::MediaContainer(std::istream* response, PlexServer* Server) m_sTitle = GetNodeValue(pAttribs->getNamedItem("title")); m_sTitle1 = GetNodeValue(pAttribs->getNamedItem("title1")); m_sTitle2 = GetNodeValue(pAttribs->getNamedItem("title2")); + m_sGrandparentTitle = GetNodeValue(pAttribs->getNamedItem("grandparentTitle")); m_iParentIndex = GetNodeValueAsInt(pAttribs->getNamedItem("parentIndex")); m_sThumb = GetNodeValue(pAttribs->getNamedItem("thumb")); m_sBanner = GetNodeValue(pAttribs->getNamedItem("banner")); diff --git a/MediaContainer.h b/MediaContainer.h index da2a210..0a538ed 100644 --- a/MediaContainer.h +++ b/MediaContainer.h @@ -53,6 +53,7 @@ public: std::string m_sTitle; std::string m_sTitle1; std::string m_sTitle2; + std::string m_sGrandparentTitle; std::string m_sViewGroup; int m_iLibrarySectionID; std::string m_sLibrarySectionTitle; @@ -213,12 +213,25 @@ void Video::AddTokens(std::shared_ptr<cOsdElement> grid, bool clear, std::functi { if(clear) grid->ClearTokens(); grid->AddStringToken("title", m_sTitle); - + grid->AddStringToken("orginaltitle", m_sOriginalTitle); + grid->AddStringToken("summary", m_sSummary); + grid->AddStringToken("contentrating", m_sContentRating); + grid->AddStringToken("studio", m_sStudio); + grid->AddIntToken("viewoffset", m_lViewoffset/1000); + grid->AddIntToken("duration", m_iDuration); + grid->AddIntToken("year", m_iYear); + + // Thumb, Cover, Episodepicture bool cached = false; - //cPictureCache::GetInstance().GetPath(ArtUri(), Config::GetInstance().ArtWidth(), Config::GetInstance().ArtHeight(), cached); std::string thumb = cPictureCache::GetInstance().GetPath(ThumbUri(), Config::GetInstance().ThumbWidth(), Config::GetInstance().ThumbHeight(), cached, OnCached, this); grid->AddIntToken("hasthumb", cached); if (cached) grid->AddStringToken("thumb", thumb); + + // Fanart + cached = false; + std::string art = cPictureCache::GetInstance().GetPath(ArtUri(), Config::GetInstance().ArtWidth(), Config::GetInstance().ArtHeight(), cached); + grid->AddIntToken("hasart", cached); + if (cached) grid->AddStringToken("art", art); if(m_tType == MediaType::MOVIE) { grid->AddIntToken("ismovie", true); @@ -226,12 +239,19 @@ void Video::AddTokens(std::shared_ptr<cOsdElement> grid, bool clear, std::functi if(m_tType == MediaType::EPISODE) { grid->AddIntToken("isepisode", true); + std::string seriesTitle = m_sGrandparentTitle; + if(seriesTitle.empty() && m_pParent) seriesTitle = m_pParent->m_sGrandparentTitle; + grid->AddStringToken("seriestitle", seriesTitle); + grid->AddIntToken("season", m_iParentIndex); + grid->AddIntToken("episode", m_iIndex); + + // Seriescover, Seasoncover cached = false; std::string grandparentThumb = cPictureCache::GetInstance().GetPath(m_pServer->GetUri() + m_sGrandparentThumb, Config::GetInstance().ThumbWidth(), Config::GetInstance().ThumbHeight(), cached, OnCached, this); - grid->AddIntToken("hasgrandparentthumb", cached); - if (cached) grid->AddStringToken("grandparentthumb", grandparentThumb); - grid->AddStringToken("grandparenttitle", m_sGrandparentTitle); + grid->AddIntToken("hasseriesthumb", cached); + if (cached) grid->AddStringToken("seriesthumb", grandparentThumb); + // Banner, Seriesbanner if(m_pParent && !m_pParent->m_sBanner.empty()) { cached = false; std::string banner = cPictureCache::GetInstance().GetPath(m_pServer->GetUri() + m_pParent->m_sBanner, Config::GetInstance().BannerWidth(), Config::GetInstance().BannerHeight(), cached, OnCached, this); diff --git a/browserGrid.cpp b/browserGrid.cpp index f3637c6..6a0417f 100644 --- a/browserGrid.cpp +++ b/browserGrid.cpp @@ -11,6 +11,7 @@ cBrowserGrid::cBrowserGrid(cOsdView* rootView) : cViewGridNavigator(rootView, ro m_pBackground = std::shared_ptr<cViewElement>(rootView->GetViewElement(eViewElementsRoot::verBackground)); m_pViewHeader = std::shared_ptr<cViewHeader>( new cViewHeader(rootView->GetViewElement(eViewElementsRoot::verHeader))); m_pfooter = std::shared_ptr<cViewElement>(rootView->GetViewElement(eViewElementsRoot::verFooter)); + m_pInfopane = std::shared_ptr<cViewElement>(rootView->GetViewElement(eViewElementsRoot::verInfopane)); m_rows = Config::GetInstance().GridRows; m_columns = Config::GetInstance().GridColumns; @@ -19,10 +20,17 @@ cBrowserGrid::cBrowserGrid(cOsdView* rootView) : cViewGridNavigator(rootView, ro SwitchGrid(m_pViewHeader->CurrentTab()); } +cBrowserGrid::~cBrowserGrid() +{ + m_vServerElements.clear(); + m_vElements.clear(); +} + void cBrowserGrid::Flush() { cMutexLock MutexLock(&cPlexSdOsd::RedrawMutex); m_pBackground->Display(); + m_pInfopane->Display(); m_pGrid->Display(); m_pRootView->Display(); } @@ -131,13 +139,14 @@ eOSState cBrowserGrid::NavigateBack() if(pCont) { m_pContainer = pCont; ProcessData(); - return eOSState::osBack; + return eOSState::osContinue; } else if(m_bServersAreRoot) { m_pContainer = NULL; m_pService = NULL; SetServerElements(); ProcessData(); + return eOSState::osContinue; } return eOSState::osEnd; } @@ -146,6 +155,7 @@ void cBrowserGrid::DrawGrid() { DrawBackground(); m_pViewHeader->Draw(SelectedObject()); + DrawInfopane(); DrawFooter(); } @@ -163,6 +173,12 @@ void cBrowserGrid::DrawBackground() m_pBackground->AddStringToken("currentdirectorybackground", "/path"); } +void cBrowserGrid::DrawInfopane() +{ + m_pInfopane->Clear(); + SelectedObject()->AddTokens(m_pInfopane, true); +} + void cBrowserGrid::DrawFooter() { //if (!active) @@ -176,7 +192,6 @@ void cBrowserGrid::DrawFooter() if(auto vid = dynamic_cast<plexclient::Video*>(SelectedObject()) ) { if(vid->m_iViewCount > 0) textRed = tr("Unscrobble"); else textRed = tr("Scrobble"); - textBlue = tr("Info"); } diff --git a/browserGrid.h b/browserGrid.h index 2eed86c..ce641b4 100644 --- a/browserGrid.h +++ b/browserGrid.h @@ -38,6 +38,7 @@ private: std::shared_ptr<cViewHeader> m_pViewHeader; std::shared_ptr<cViewElement> m_pBackground; std::shared_ptr<cViewElement> m_pfooter; + std::shared_ptr<cViewElement> m_pInfopane; std::shared_ptr<cViewElement> m_pScrollbar; bool m_bServersAreRoot; @@ -50,9 +51,11 @@ private: void SetServerElements(); void DrawFooter(); void DrawBackground(); + void DrawInfopane(); public: cBrowserGrid(cOsdView* rootView); + ~cBrowserGrid(); //cBrowserGrid(cViewGrid* viewGrid, std::shared_ptr<plexclient::Plexservice> service); std::shared_ptr<plexclient::MediaContainer> MediaContainer() { return m_pContainer; } @@ -12,6 +12,7 @@ ////////////////////////////////////////////////////////////////////////////// volatile bool cMyPlugin::CalledFromCode = false; +bool cMyPlugin::bSkindesigner = false; /** ** Initialize any member variables here. @@ -59,22 +60,24 @@ bool cMyPlugin::Start(void) { RegisterPlugin reg; reg.name = "plex"; - + reg.SetView(viRootView, "root.xml"); reg.SetViewGrid(eViews::viRootView, eViewGrids::vgBrowser, "browser"); reg.SetViewElement(viRootView, verHeader, "header"); reg.SetViewElement(viRootView, verBackground, "background"); + reg.SetViewElement(viRootView, verInfopane, "infopane"); reg.SetViewElement(viRootView, verFooter, "footer"); - + reg.SetSubView(viRootView, viDetailView, "detail.xml"); - reg.SetViewElement(viDetailView, vedBackground, "background"); - reg.SetViewElement(viDetailView, vedHeader, "header"); - reg.SetViewElement(viDetailView, vedFooter, "footer"); - + reg.SetViewElement(viDetailView, vedBackground, "background"); + reg.SetViewElement(viDetailView, vedHeader, "header"); + reg.SetViewElement(viDetailView, vedFooter, "footer"); + static cPlugin *pSkinDesigner = cPluginManager::GetPlugin("skindesigner"); if (pSkinDesigner) { pSkinDesigner->Service("RegisterPlugin", ®); m_pSdCheck = new cPlexSdOsd(); + cMyPlugin::bSkindesigner = m_pSdCheck->SdSupport(); } else { esyslog("[plex]: skindesigner not available"); } @@ -162,7 +165,7 @@ bool cMyPlugin::SetupParse(const char *name, const char *value) else if (strcasecmp(name, "GridColumns") == 0) Config::GetInstance().GridColumns = atoi(value); else if (strcasecmp(name, "GridRows") == 0) Config::GetInstance().GridRows = atoi(value); else return false; - + return true; } @@ -175,10 +178,15 @@ void cMyPlugin::PlayFile(plexclient::Video Vid) { isyslog("[plex]: play file '%s'\n", Vid.m_sKey.c_str()); if(Vid.m_iMyPlayOffset == 0 && Vid.m_lViewoffset > 0 ) { - cString message = cString::sprintf(tr("To start from %ld minutes, press Ok."), Vid.m_lViewoffset / 60000); - eKeys response = Skins.Message(eMessageType::mtInfo, message, 5); - if(response == kOk) { - Vid.m_iMyPlayOffset = Vid.m_lViewoffset/1000; + if(cMyPlugin::bSkindesigner) { + // we have skindesigner + + } else { + cString message = cString::sprintf(tr("To start from %ld minutes, press Ok."), Vid.m_lViewoffset / 60000); + eKeys response = Skins.Message(eMessageType::mtInfo, message, 5); + if(response == kOk) { + Vid.m_iMyPlayOffset = Vid.m_lViewoffset/1000; + } } } cControl* control = cHlsPlayerControl::Create(Vid); @@ -41,6 +41,7 @@ class cMyPlugin:public cPlugin { private: cPlexSdOsd* m_pSdCheck; + static bool bSkindesigner; public: cMyPlugin(void); diff --git a/plexSdOsd.cpp b/plexSdOsd.cpp index 6e3ae17..376f857 100644 --- a/plexSdOsd.cpp +++ b/plexSdOsd.cpp @@ -18,7 +18,7 @@ bool cPlexSdOsd::SdSupport() { bool skinDesignerAvailable = InitSkindesignerInterface("plex"); if (skinDesignerAvailable) { - + cOsdView *rootView = GetOsdView(eViews::viRootView); if (!rootView) { esyslog("[plex]: used skindesigner skin does not support plex"); @@ -54,6 +54,7 @@ void cPlexSdOsd::Flush() eOSState cPlexSdOsd::ProcessKey(eKeys Key) { eOSState state = eOSState::osContinue; + plexclient::Video* vid = dynamic_cast<plexclient::Video*>(m_pBrowserGrid->SelectedObject()); switch (Key & ~k_Repeat) { case kUp: m_pBrowserGrid->NavigateUp(); @@ -82,15 +83,21 @@ eOSState cPlexSdOsd::ProcessKey(eKeys Key) Flush(); break; case kRed: - // Prev Tab - m_pBrowserGrid->NextTab(); - Flush(); + if(vid) { + if(vid->m_iViewCount > 0) vid->SetUnwatched(); + else vid->SetWatched(); + vid->UpdateFromServer(); + Flush(); + } break; case kGreen: - // Next Tab m_pBrowserGrid->PrevTab(); Flush(); break; + case kYellow: + m_pBrowserGrid->NextTab(); + Flush(); + break; default: break; } diff --git a/plexSdOsd.h b/plexSdOsd.h index 2cc5508..b039aa5 100644 --- a/plexSdOsd.h +++ b/plexSdOsd.h @@ -28,7 +28,8 @@ enum eViews { enum eViewElementsRoot { verBackground, verHeader, - verFooter + verFooter, + verInfopane }; enum eViewGrids { diff --git a/skins/blackhole/xmlfiles/plug-plex-root.xml b/skins/blackhole/xmlfiles/plug-plex-root.xml index b67e9c1..67c5a2c 100644 --- a/skins/blackhole/xmlfiles/plug-plex-root.xml +++ b/skins/blackhole/xmlfiles/plug-plex-root.xml @@ -51,6 +51,14 @@ </area> </viewelement> + <viewelement name="infopane"> + <area layer="2" x="75%" y="15%" width="25%" height="75%"> + <drawtext x="1%" y="2%" width="98%" font="{light}" fontsize="5%" color="{clrWhite}" text="{title}" /> + <drawimage condition="{hasart}" imagetype="image" path="{art}" x="0" y="8%" width="100%" height="35%" /> + <drawtextbox x="1%" y="40%" width="96%" float="topright" font="{light}" fontsize="3%" color="{clrWhite}" text="{summary}" /> + </area> + </viewelement> + <!-- Tokens available in browser {current} Currently active element {title} Name of the element @@ -79,7 +87,7 @@ {banner} --> - <grid name="browser" x="0" y="15%" width="100%" height="75%"> + <grid name="browser" x="0" y="15%" width="75%" height="75%"> <area layer="3"> <drawtext x="1%" y="2%" width="98%" font="{light}" fontsize="5%" color="{clrWhite}" text="{title}" /> <drawtext condition="{current}" x="1%" y="20%" width="98%" font="{light}" fontsize="5%" color="{clrWhite}" text="Active" /> |