Permalink
Browse files

[resume] cleanup GetResumeString to reuse GetResumeItemOffset

  • Loading branch information...
1 parent 43739d2 commit 18e16d8a3e7b7a6989eb583269c68958af381014 Jonathan Marshall committed Jul 8, 2012
Showing with 19 additions and 29 deletions.
  1. +14 −27 xbmc/video/windows/GUIWindowVideoBase.cpp
  2. +5 −2 xbmc/video/windows/GUIWindowVideoBase.h
View
41 xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -895,7 +895,6 @@ bool CGUIWindowVideoBase::OnFileAction(int iItem, int action)
case SELECT_ACTION_CHOOSE:
{
CContextButtons choices;
- bool resume = false;
if (item->IsVideoDb())
{
@@ -905,17 +904,13 @@ bool CGUIWindowVideoBase::OnFileAction(int iItem, int action)
choices.Add(SELECT_ACTION_PLAYPART, 20324); // Play Part
}
- if (!item->IsLiveTV())
+ CStdString resumeString = GetResumeString(*item);
+ if (!resumeString.IsEmpty())
{
- CStdString resumeString = GetResumeString(*item);
- if (!resumeString.IsEmpty())
- {
- resume = true;
- choices.Add(SELECT_ACTION_RESUME, resumeString);
- choices.Add(SELECT_ACTION_PLAY, 12021); // Start from beginning
- }
+ choices.Add(SELECT_ACTION_RESUME, resumeString);
+ choices.Add(SELECT_ACTION_PLAY, 12021); // Start from beginning
}
- if (!resume)
+ else
choices.Add(SELECT_ACTION_PLAY, 208); // Play
choices.Add(SELECT_ACTION_INFO, 22081); // Info
@@ -1003,28 +998,20 @@ void CGUIWindowVideoBase::OnRestartItem(int iItem)
CGUIMediaWindow::OnClick(iItem);
}
-CStdString CGUIWindowVideoBase::GetResumeString(CFileItem item)
+CStdString CGUIWindowVideoBase::GetResumeString(const CFileItem &item)
{
CStdString resumeString;
- CStdString partString;
- CVideoDatabase db;
- if (db.Open())
+ int startOffset = 0, startPart = 0;
+ GetResumeItemOffset(&item, startOffset, startPart);
+ if (startOffset > 0)
{
- CBookmark bookmark;
- CStdString itemPath(item.GetPath());
- if (item.IsVideoDb() || item.IsDVD())
- itemPath = item.GetVideoInfoTag()->m_strFileNameAndPath;
-
- if (db.GetResumeBookMark(itemPath, bookmark))
+ resumeString.Format(g_localizeStrings.Get(12022).c_str(), StringUtils::SecondsToTimeString(startOffset/75).c_str());
+ if (startPart > 0)
{
- resumeString.Format(g_localizeStrings.Get(12022).c_str(), StringUtils::SecondsToTimeString(lrint(bookmark.timeInSeconds)).c_str());
- if (bookmark.partNumber > 0)
- {
- partString.Format(g_localizeStrings.Get(23051).c_str(), bookmark.partNumber);
- resumeString.append(" (").append(partString).append(")");
- }
+ CStdString partString;
+ partString.Format(g_localizeStrings.Get(23051).c_str(), startPart);
+ resumeString += " (" + partString + ")";
}
- db.Close();
}
return resumeString;
}
View
7 xbmc/video/windows/GUIWindowVideoBase.h
@@ -50,7 +50,10 @@ class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObse
/*! \brief Show the resume menu for this item (if it has a resume bookmark)
- If a resume bookmark is found, we set the item's m_lStartOffset to STARTOFFSET_RESUME
+ If a resume bookmark is found, we set the item's m_lStartOffset to STARTOFFSET_RESUME.
+ Note that we do this in favour of setting the resume point, as we need additional
+ information from the database (in particular, the playerState) when resuming some items
+ (eg ISO/VIDEO_TS).
\param item item to check for a resume bookmark
\return true if an option was chosen, false if the resume menu was cancelled.
*/
@@ -77,7 +80,7 @@ class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObse
\param item selected item
\return string containing the resume position or an empty string if there is no resume position
*/
- static CStdString GetResumeString(CFileItem item);
+ static CStdString GetResumeString(const CFileItem &item);
protected:
void OnScan(const CStdString& strPath, bool scanAll = false);

0 comments on commit 18e16d8

Please sign in to comment.