Skip to content

Commit

Permalink
[pvr] changed: ask if the user wants to resume from the beginning of …
Browse files Browse the repository at this point in the history
…a recording when starting playback on a channel and a matching recording is found
  • Loading branch information
opdenkamp committed Mar 5, 2015
1 parent 608e78d commit e58b684
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
14 changes: 14 additions & 0 deletions xbmc/pvr/channels/PVRChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions xbmc/pvr/channels/PVRChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
25 changes: 23 additions & 2 deletions xbmc/pvr/windows/GUIWindowPVRBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()))
Expand Down

0 comments on commit e58b684

Please sign in to comment.