diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 8dd2dfe5a0d74..9abfc581915b0 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -76,7 +76,7 @@ #include "pvr/PVRManager.h" #include "pvr/channels/PVRChannelGroupsContainer.h" -#include "epg/EpgInfoTag.h" +#include "epg/EpgContainer.h" #include "pvr/timers/PVRTimers.h" #include "pvr/recordings/PVRRecording.h" @@ -414,7 +414,8 @@ const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE }, { "hasepg", VIDEOPLAYER_HAS_EPG }, { "parentalrating", VIDEOPLAYER_PARENTAL_RATING }, { "isstereoscopic", VIDEOPLAYER_IS_STEREOSCOPIC }, - { "stereoscopicmode", VIDEOPLAYER_STEREOSCOPIC_MODE } + { "stereoscopicmode", VIDEOPLAYER_STEREOSCOPIC_MODE }, + { "canresumelivetv", VIDEOPLAYER_CAN_RESUME_LIVE_TV }, }; const infomap mediacontainer[] = {{ "hasfiles", CONTAINER_HASFILES }, @@ -2675,6 +2676,13 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI bReturn = !m_videoInfo.stereoMode.empty(); } break; + case VIDEOPLAYER_CAN_RESUME_LIVE_TV: + if (m_currentFile->HasPVRRecordingInfoTag()) + { + EPG::CEpgInfoTagPtr epgTag = EPG::CEpgContainer::Get().GetTagById(m_currentFile->GetPVRRecordingInfoTag()->EpgEvent()); + bReturn = (epgTag && epgTag->IsActive() && epgTag->ChannelTag()); + } + break; default: // default, use integer value different from 0 as true { int val; diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index 20fe8108b8330..3ccd4f9bcc048 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -285,6 +285,7 @@ namespace INFO #define VIDEOPLAYER_AUDIO_LANG 313 #define VIDEOPLAYER_SUB_CHANNEL_NUMBER 314 #define VIDEOPLAYER_CHANNEL_NUMBER_LBL 315 +#define VIDEOPLAYER_CAN_RESUME_LIVE_TV 316 #define CONTAINER_CAN_FILTER 342 #define CONTAINER_CAN_FILTERADVANCED 343 diff --git a/xbmc/interfaces/Builtins.cpp b/xbmc/interfaces/Builtins.cpp index b97541e0c5fa4..6da94920d3643 100644 --- a/xbmc/interfaces/Builtins.cpp +++ b/xbmc/interfaces/Builtins.cpp @@ -67,6 +67,8 @@ #include "URL.h" #include "music/MusicDatabase.h" #include "cores/IPlayer.h" +#include "pvr/channels/PVRChannel.h" +#include "pvr/recordings/PVRRecording.h" #include "filesystem/PluginDirectory.h" #ifdef HAS_FILESYSTEM_RAR @@ -1063,6 +1065,21 @@ int CBuiltins::Execute(const std::string& execString) CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_REPEAT, 0, 0, iPlaylist, (int)state); g_windowManager.SendThreadMessage(msg); } + else if (StringUtils::StartsWithNoCase(parameter, "resumelivetv")) + { + CFileItem& fileItem(g_application.CurrentFileItem()); + PVR::CPVRChannelPtr channel = fileItem.HasPVRRecordingInfoTag() ? fileItem.GetPVRRecordingInfoTag()->Channel() : PVR::CPVRChannelPtr(); + + if (channel) + { + CFileItem playItem(channel); + if (!g_application.PlayMedia(playItem, channel->IsRadio() ? PLAYLIST_MUSIC : PLAYLIST_VIDEO)) + { + CLog::Log(LOGERROR, "ResumeLiveTv could not play channel: %s", channel->ChannelName().c_str()); + return false; + } + } + } } else if (execute == "playwith") { diff --git a/xbmc/pvr/recordings/PVRRecording.cpp b/xbmc/pvr/recordings/PVRRecording.cpp index 4327b67b699a1..f6f44b91fe148 100644 --- a/xbmc/pvr/recordings/PVRRecording.cpp +++ b/xbmc/pvr/recordings/PVRRecording.cpp @@ -19,6 +19,7 @@ */ #include "dialogs/GUIDialogOK.h" +#include "epg/EpgContainer.h" #include "pvr/PVRManager.h" #include "settings/AdvancedSettings.h" #include "PVRRecordings.h" @@ -418,3 +419,14 @@ void CPVRRecording::CopyClientInfo(CVideoInfoTag *target) const target->m_playCount = m_playCount; target->m_resumePoint = m_resumePoint; } + +CPVRChannelPtr CPVRRecording::Channel(void) const +{ + if (m_iEpgEventId) + { + EPG::CEpgInfoTagPtr epgTag = EPG::CEpgContainer::Get().GetTagById(m_iEpgEventId); + if (epgTag) + return epgTag->ChannelTag(); + } + return CPVRChannelPtr(); +} diff --git a/xbmc/pvr/recordings/PVRRecording.h b/xbmc/pvr/recordings/PVRRecording.h index 513d33df37d72..cc94d4de9df98 100644 --- a/xbmc/pvr/recordings/PVRRecording.h +++ b/xbmc/pvr/recordings/PVRRecording.h @@ -48,9 +48,11 @@ class CVideoDatabase; namespace PVR { class CPVRRecording; - typedef std::shared_ptr CPVRRecordingPtr; + class CPVRChannel; + typedef std::shared_ptr CPVRChannelPtr; + /*! * @brief Representation of a CPVRRecording unique ID. */ @@ -203,6 +205,11 @@ namespace PVR */ int EpgEvent(void) const { return m_iEpgEventId; } + /*! + * @return Get the channel on which this recording is/was running + */ + CPVRChannelPtr Channel(void) const; + private: CDateTime m_recordingTime; /*!< start time of the recording */ bool m_bGotMetaData;