diff options
author | chriszero <zerov83@gmail.com> | 2015-01-14 21:50:20 +0100 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2015-01-14 21:50:20 +0100 |
commit | adc0c699c19b0389b899230a73f3ab635bcdc5c3 (patch) | |
tree | b57b71b338cea70dfc4b2e7b92ddb73be06184b7 | |
parent | acbfb7d0bb54a591332dc9030ae377dcfac19fac (diff) | |
download | vdr-plugin-plex-adc0c699c19b0389b899230a73f3ab635bcdc5c3.tar.gz vdr-plugin-plex-adc0c699c19b0389b899230a73f3ab635bcdc5c3.tar.bz2 |
Implemented Play, Pause, Stop
-rw-r--r-- | hlsPlayer.cpp | 22 | ||||
-rw-r--r-- | hlsPlayer.h | 7 | ||||
-rw-r--r-- | hlsPlayerControl.cpp | 82 | ||||
-rw-r--r-- | hlsPlayerControl.h | 16 |
4 files changed, 120 insertions, 7 deletions
diff --git a/hlsPlayer.cpp b/hlsPlayer.cpp index cf52a6a..326f071 100644 --- a/hlsPlayer.cpp +++ b/hlsPlayer.cpp @@ -2,7 +2,7 @@ #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> -#include <Poco/StreamCopier.h> +//#include <Poco/StreamCopier.h> #include <pcrecpp.h> @@ -118,6 +118,7 @@ bool cHlsSegmentLoader::LoadStartList(void) res = m_startParser.Parse(startFile); if(res) { + // Get GUID pcrecpp::RE re("([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})", pcrecpp::RE_Options(PCRE_CASELESS)); string value; re.PartialMatch(m_startParser.vPlaylistItems[0].file, &value); @@ -239,7 +240,7 @@ bool cHlsSegmentLoader::BufferFilled(void) bool cHlsSegmentLoader::StopLoader(void) { dsyslog("[plex]%s", __FUNCTION__); - std::string stopUri = "/video/:/transcode/segmented/stop?session=" + m_sessionCookie; + std::string stopUri = "/video/:/transcode/universal/stop?session=" + m_sessionCookie; Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, stopUri); m_pClientSession->sendRequest(req); Poco::Net::HTTPResponse reqResponse; @@ -258,6 +259,11 @@ void cHlsSegmentLoader::AddHeader(Poco::Net::HTTPRequest& req) req.add("X-Plex-Model", "Linux"); } +bool cHlsSegmentLoader::Active(void) +{ + return Running(); +} + //--- cHlsPlayer cHlsPlayer::cHlsPlayer(std::string startm3u8) @@ -359,3 +365,15 @@ void cHlsPlayer::Play(void) playMode = pmPlay; } } + +bool cHlsPlayer::Active(void) +{ + return Running() && m_pSegmentLoader && m_pSegmentLoader->Active(); +} + +void cHlsPlayer::Stop(void) +{ + if (m_pSegmentLoader) + m_pSegmentLoader->StopLoader(); + Cancel(1); +} diff --git a/hlsPlayer.h b/hlsPlayer.h index a07a4bf..4ba017e 100644 --- a/hlsPlayer.h +++ b/hlsPlayer.h @@ -49,14 +49,15 @@ protected: void Action(void); bool DoLoad(void); void AddHeader(Poco::Net::HTTPRequest& req); - bool StopLoader(void); public: cHlsSegmentLoader(std::string startm3u8); ~cHlsSegmentLoader(); cRingBufferLinear* m_pRingbuffer; - bool BufferFilled(); + bool BufferFilled(void); + bool Active(void); + bool StopLoader(void); }; class cHlsPlayer : public cPlayer, cThread @@ -87,6 +88,8 @@ public: virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed); void Pause(void); void Play(void); + void Stop(void); + bool Active(void); }; diff --git a/hlsPlayerControl.cpp b/hlsPlayerControl.cpp index f572604..97be2d7 100644 --- a/hlsPlayerControl.cpp +++ b/hlsPlayerControl.cpp @@ -2,7 +2,7 @@ cHlsPlayerControl::cHlsPlayerControl(cHlsPlayer* Player, std::string title) :cControl(Player) { - m_pPlayer = Player; + player = Player; m_title = title; } @@ -22,3 +22,83 @@ void cHlsPlayerControl::Hide(void) void cHlsPlayerControl::Show(void) { } + +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; + } + 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: + //SkipSeconds(-60); + break; + case kYellow|k_Repeat: + case kYellow: + //SkipSeconds( 60); + break; + case kStop: + case kBlue: + Hide(); + Stop(); + return osEnd; + } + 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(); +} diff --git a/hlsPlayerControl.h b/hlsPlayerControl.h index 934feff..36c23ee 100644 --- a/hlsPlayerControl.h +++ b/hlsPlayerControl.h @@ -9,8 +9,13 @@ class cHlsPlayerControl : public cControl { private: - cHlsPlayer* m_pPlayer; + cHlsPlayer* player; std::string m_title; + + bool visible; + +protected: + //void ShowMode(); public: cHlsPlayerControl(cHlsPlayer* Player, std::string title); @@ -20,7 +25,14 @@ public: virtual void Hide(void); virtual cString GetHeader(void); - //virtual eOSState ProcessKey(eKeys Key); + virtual eOSState ProcessKey(eKeys Key); + + bool Active(void); + + void Pause(void); + void Play(void); + void Stop(void); + }; |