From e58b6844202661b5a7548af1382357785cbcc53d Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sat, 28 Feb 2015 20:05:53 +0100 Subject: [PATCH] [pvr] changed: ask if the user wants to resume from the beginning of a recording when starting playback on a channel and a matching recording is found --- xbmc/pvr/channels/PVRChannel.cpp | 14 ++++++++++++++ xbmc/pvr/channels/PVRChannel.h | 10 ++++++++++ xbmc/pvr/windows/GUIWindowPVRBase.cpp | 25 +++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index 598c132be6cc8..72e1cd8668f26 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -294,6 +294,20 @@ bool CPVRChannel::IsRecording(void) const return g_PVRTimers->IsRecordingOnChannel(*this); } +CPVRRecordingPtr CPVRChannel::GetRecording(void) const +{ + EPG::CEpgInfoTagPtr epgTag = GetEPGNow(); + return (epgTag && epgTag->HasRecording()) ? + epgTag->Recording() : + CPVRRecordingPtr(); +} + +bool CPVRChannel::HasRecording(void) const +{ + EPG::CEpgInfoTagPtr epgTag = GetEPGNow(); + return epgTag && epgTag->HasRecording(); +} + bool CPVRChannel::SetIconPath(const std::string &strIconPath, bool bIsUserSetIcon /* = false */) { CSingleLock lock(m_critSection); diff --git a/xbmc/pvr/channels/PVRChannel.h b/xbmc/pvr/channels/PVRChannel.h index 4d38ad11fed79..88accc8960c86 100644 --- a/xbmc/pvr/channels/PVRChannel.h +++ b/xbmc/pvr/channels/PVRChannel.h @@ -179,6 +179,16 @@ namespace PVR */ bool IsRecording(void) const; + /*! + * @return If recording, gets the recording if the add-on provides the epg id in recordings + */ + CPVRRecordingPtr GetRecording(void) const; + + /*! + * @return True if this channel has a corresponding recording, false otherwise + */ + bool HasRecording(void) const; + /*! * @return The path to the icon for this channel. */ diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp index a3de78537f6dc..7dd89411d7c1c 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp @@ -273,7 +273,9 @@ bool CGUIWindowPVRBase::PlayFile(CFileItem *item, bool bPlayMinimized /* = false return false; } - if (item->GetPath() == g_application.CurrentFile()) + CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; + if (item->GetPath() == g_application.CurrentFile() || + (channel && channel->HasRecording() && channel->GetRecording()->GetPath() == g_application.CurrentFile())) { CGUIMessage msg(GUI_MSG_FULLSCREEN, 0, GetID()); g_windowManager.SendMessage(msg); @@ -289,11 +291,30 @@ bool CGUIWindowPVRBase::PlayFile(CFileItem *item, bool bPlayMinimized /* = false else { bool bSwitchSuccessful(false); - CPVRChannelPtr channel(item->GetPVRChannelInfoTag()); if (channel && g_PVRManager.CheckParentalLock(channel)) { + CPVRRecordingPtr recording = channel->GetRecording(); + if (recording) + { + CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*) g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); + if (pDialog) + { + pDialog->SetHeading(19687); // Play recording + pDialog->SetLine(0, ""); + pDialog->SetLine(1, 12021); // Start from beginning + pDialog->SetLine(2, recording->m_strTitle.c_str()); + pDialog->DoModal(); + + if (pDialog->IsConfirmed()) + { + CFileItem recordingItem(recording); + return PlayRecording(&recordingItem, CSettings::Get().GetBool("pvrplayback.playminimized")); + } + } + } + /* try a fast switch */ if ((g_PVRManager.IsPlayingTV() || g_PVRManager.IsPlayingRadio()) && (channel->IsRadio() == g_PVRManager.IsPlayingRadio()))