aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmarshallnz <jcmarsha@gmail.com>2014-05-18 09:19:07 +1200
committerjmarshallnz <jcmarsha@gmail.com>2014-05-18 09:19:07 +1200
commitb876643f64a3c51c9dcb4c7e90eee15a46505c88 (patch)
tree71c5ce01e8f1a21b6bfe2465f58ea8a085b91a14
parent692cfbaa90975efd660beff38675e6a7041e2e23 (diff)
parentdff4d1e5421f912de1b07f069f7e4a68e9fd183e (diff)
Merge pull request #4630 from Red-F/gotham-resume-pvr-lastplayedposition
FIX resume playing PVR recordings from the exact lastplayed position
-rw-r--r--xbmc/Application.cpp4
-rw-r--r--xbmc/FileItem.cpp23
-rw-r--r--xbmc/FileItem.h12
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRRecordings.cpp17
4 files changed, 39 insertions, 17 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index b7eaca31ec..0561286879 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -4004,8 +4004,8 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
should the playerState be required, it is fetched from the database.
See the note in CGUIWindowVideoBase::ShowResumeMenu.
*/
- if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_resumePoint.IsSet())
- options.starttime = item.GetVideoInfoTag()->m_resumePoint.timeInSeconds;
+ if (item.IsResumePointSet())
+ options.starttime = item.GetCurrentResumeTime();
}
else if (item.HasVideoInfoTag())
{
diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp
index eb0e4a5cc4..75f70b81f9 100644
--- a/xbmc/FileItem.cpp
+++ b/xbmc/FileItem.cpp
@@ -3320,3 +3320,26 @@ int CFileItem::GetVideoContentType() const
return type;
}
+bool CFileItem::IsResumePointSet() const
+{
+ return (HasVideoInfoTag() && GetVideoInfoTag()->m_resumePoint.IsSet()) ||
+ (HasPVRRecordingInfoTag() && GetPVRRecordingInfoTag()->GetLastPlayedPosition() > 0);
+}
+
+double CFileItem::GetCurrentResumeTime() const
+{
+ if (HasPVRRecordingInfoTag())
+ {
+ // This will retrieve 'fresh' resume information from the PVR server
+ int rc = GetPVRRecordingInfoTag()->GetLastPlayedPosition();
+ if (rc > 0)
+ return rc;
+ // Fall through to default value
+ }
+ if (HasVideoInfoTag() && GetVideoInfoTag()->m_resumePoint.IsSet())
+ {
+ return GetVideoInfoTag()->m_resumePoint.timeInSeconds;
+ }
+ // Resume from start when resume points are invalid or the PVR server returns an error
+ return 0;
+}
diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h
index 286bd349b2..56df810036 100644
--- a/xbmc/FileItem.h
+++ b/xbmc/FileItem.h
@@ -295,6 +295,18 @@ public:
return m_pvrTimerInfoTag;
}
+ /*!
+ \brief Test if this item has a valid resume point set.
+ \return True if this item has a resume point and it is set, false otherwise.
+ */
+ bool IsResumePointSet() const;
+
+ /*!
+ \brief Return the current resume time.
+ \return The time in seconds from the start to resume playing from.
+ */
+ double GetCurrentResumeTime() const;
+
inline bool HasPictureInfoTag() const
{
return m_pictureInfoTag != NULL;
diff --git a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp
index feb39008de..573b46493f 100644
--- a/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp
+++ b/xbmc/pvr/windows/GUIWindowPVRRecordings.cpp
@@ -70,21 +70,8 @@ CStdString CGUIWindowPVRRecordings::GetResumeString(const CFileItem& item)
// First try to find the resume position on the back-end, if that fails use video database
int positionInSeconds = item.GetPVRRecordingInfoTag()->GetLastPlayedPosition();
- // If the back-end does report a saved position then make sure there is a corresponding resume bookmark
- if (positionInSeconds > 0)
- {
- CBookmark bookmark;
- bookmark.timeInSeconds = positionInSeconds;
- bookmark.totalTimeInSeconds = (double)item.GetPVRRecordingInfoTag()->GetDuration();
- CVideoDatabase db;
- if (db.Open())
- {
- CStdString itemPath(item.GetPVRRecordingInfoTag()->m_strFileNameAndPath);
- db.AddBookMarkToFile(itemPath, bookmark, CBookmark::RESUME);
- db.Close();
- }
- }
- else if (positionInSeconds < 0)
+ // If the back-end does report a saved position it will be picked up by FileItem
+ if (positionInSeconds < 0)
{
CVideoDatabase db;
if (db.Open())