Browse files

Merge pull request #1220 from jmarshallnz/cleanup_resume

Cleanup resume
  • Loading branch information...
2 parents ba01989 + d82d1a7 commit 6791924b4686a24b7cfa4d4518b8143bc61da80f @jmarshallnz jmarshallnz committed Aug 3, 2012
View
8 xbmc/Application.cpp
@@ -4012,6 +4012,14 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart)
options.starttime = bookmark.timeInSeconds;
options.state = bookmark.playerState;
}
+ /*
+ override with information from the actual item if available. We do this as the VFS (eg plugins)
+ may set the resume point to override whatever XBMC has stored, yet we ignore it until now so that,
+ 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;
}
else if (item.HasVideoInfoTag())
{
View
2 xbmc/GUIInfoManager.cpp
@@ -3822,7 +3822,7 @@ bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info)
switch (info)
{
case LISTITEM_PERCENT_PLAYED:
- if (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds > 0 && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0)
+ if (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.IsPartWay())
value = (int)(100 * ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds);
else
value = 0;
View
3 xbmc/ThumbLoader.cpp
@@ -199,8 +199,7 @@ bool CVideoThumbLoader::LoadItem(CFileItem* pItem)
m_database->Open();
// resume point
- if (pItem->HasVideoInfoTag() &&
- pItem->GetVideoInfoTag()->m_resumePoint.type != CBookmark::RESUME && pItem->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds == 0)
+ if (pItem->HasVideoInfoTag() && !pItem->GetVideoInfoTag()->m_resumePoint.IsSet())
{
if (m_database->GetResumePoint(*pItem->GetVideoInfoTag()))
pItem->SetInvalid();
View
3 xbmc/filesystem/PluginDirectory.cpp
@@ -35,6 +35,7 @@
#include "dialogs/GUIDialogProgress.h"
#include "settings/GUISettings.h"
#include "FileItem.h"
+#include "video/VideoInfoTag.h"
#include "guilib/LocalizeStrings.h"
#include "utils/log.h"
#include "utils/TimeUtils.h"
@@ -148,6 +149,8 @@ bool CPluginDirectory::GetPluginResult(const CStdString& strPath, CFileItem &res
resultItem.SetPath(newDir->m_fileResult->GetPath());
resultItem.SetMimeType(newDir->m_fileResult->GetMimeType(false));
resultItem.UpdateInfo(*newDir->m_fileResult);
+ if (newDir->m_fileResult->HasVideoInfoTag() && newDir->m_fileResult->GetVideoInfoTag()->m_resumePoint.IsSet())
+ resultItem.m_lStartOffset = STARTOFFSET_RESUME; // resume point set in the resume item, so force resume
}
delete newDir;
View
16 xbmc/interfaces/python/xbmcmodule/listitem.cpp
@@ -755,13 +755,13 @@ namespace PYXBMC
" You can use the above as keywords for arguments and skip certain optional arguments.\n"
" Once you use a keyword, all following arguments require the keyword.\n"
"\n"
- " Some of these are treated internally by XBMC, such as the 'StartOffset' property, which is\n"
- " the offset in seconds at which to start playback of an item. Others may be used in the skin\n"
- " to add extra information, such as 'WatchedCount' for tvshow items\n"
+ " Some of these are treated internally by XBMC.\n"
+ " Others may be used in the skin to add extra information, such as 'WatchedCount' for tvshow items\n"
"\n"
"example:\n"
" - self.list.getSelectedItem().setProperty('AspectRatio', '1.85 : 1')\n"
- " - self.list.getSelectedItem().setProperty('StartOffset', '256.4')\n");
+ " - self.list.getSelectedItem().setProperty('TotalTime', '3668.4')\n"
+ " - self.list.getSelectedItem().setProperty('ResumeTime', '306.8')\n");
PyObject* ListItem_SetProperty(ListItem *self, PyObject *args, PyObject *kwds)
{
@@ -798,6 +798,10 @@ namespace PYXBMC
{ // special case for mime type - don't actually stored in a property,
self->item->SetMimeType(uText);
}
+ else if (lowerKey.CompareNoCase("totaltime") == 0)
+ self->item->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds = (float)atof(uText.c_str());
+ else if (lowerKey.CompareNoCase("resumetime") == 0)
+ self->item->GetVideoInfoTag()->m_resumePoint.timeInSeconds = (float)atof(uText.c_str());
else if (lowerKey.CompareNoCase("specialsort") == 0)
{
if (uText == "bottom")
@@ -851,6 +855,10 @@ namespace PYXBMC
// we store it in item.m_lStartOffset instead
value.Format("%f", self->item->m_lStartOffset / 75.0);
}
+ else if (lowerKey.CompareNoCase("totaltime") == 0)
+ value.Format("%f", self->item->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds);
+ else if (lowerKey.CompareNoCase("resumetime") == 0)
+ value.Format("%f", self->item->GetVideoInfoTag()->m_resumePoint.timeInSeconds);
else
value = self->item->GetProperty(lowerKey.ToLower()).asString();
PyXBMCGUIUnlock();
View
9 xbmc/video/Bookmark.cpp
@@ -36,3 +36,12 @@ void CBookmark::Reset()
type = STANDARD;
}
+bool CBookmark::IsSet() const
+{
+ return totalTimeInSeconds > 0.0f;
+}
+
+bool CBookmark::IsPartWay() const
+{
+ return totalTimeInSeconds > 0.0f && timeInSeconds > 0.0f;
+}
View
11 xbmc/video/Bookmark.h
@@ -29,6 +29,17 @@ class CBookmark
public:
CBookmark();
void Reset();
+
+ /*! \brief returns true if this bookmark has been set.
+ \return true if totalTimeInSeconds is positive.
+ */
+ bool IsSet() const;
+
+ /*! \brief returns true if this bookmark is part way through the video file
+ \return true if both totalTimeInSeconds and timeInSeconds are positive.
+ */
+ bool IsPartWay() const;
+
double timeInSeconds;
double totalTimeInSeconds;
long partNumber;
View
9 xbmc/video/VideoDatabase.cpp
@@ -4130,9 +4130,12 @@ bool CVideoDatabase::GetPlayCounts(const CStdString &strPath, CFileItemList &ite
if (item)
{
item->GetVideoInfoTag()->m_playCount = m_pDS->fv(1).get_asInt();
- item->GetVideoInfoTag()->m_resumePoint.timeInSeconds = m_pDS->fv(2).get_asInt();
- item->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds = m_pDS->fv(3).get_asInt();
- item->GetVideoInfoTag()->m_resumePoint.type = CBookmark::RESUME;
+ if (!item->GetVideoInfoTag()->m_resumePoint.IsSet())
+ {
+ item->GetVideoInfoTag()->m_resumePoint.timeInSeconds = m_pDS->fv(2).get_asInt();
+ item->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds = m_pDS->fv(3).get_asInt();
+ item->GetVideoInfoTag()->m_resumePoint.type = CBookmark::RESUME;
+ }
}
m_pDS->next();
}
View
1 xbmc/video/VideoDatabase.h
@@ -402,6 +402,7 @@ class CVideoDatabase : public CDatabase
void UpdateLastPlayed(const CFileItem &item);
/*! \brief Get the playcount and resume point of a list of items
+ Note that if the resume point is already set on an item, it won't be overridden.
\param path the path to fetch videos from
\param items CFileItemList to fetch the playcounts for
\sa GetPlayCount, SetPlayCount, IncrementPlayCount
View
2 xbmc/video/VideoInfoScanner.cpp
@@ -1106,7 +1106,7 @@ namespace VIDEO
m_database.SetPlayCount(*pItem, movieDetails.m_playCount, movieDetails.m_lastPlayed);
if ((g_advancedSettings.m_bVideoLibraryImportResumePoint || libraryImport) &&
- movieDetails.m_resumePoint.timeInSeconds > 0.0f && movieDetails.m_resumePoint.totalTimeInSeconds > 0.0f)
+ movieDetails.m_resumePoint.IsSet())
m_database.AddBookMarkToFile(pItem->GetPath(), movieDetails.m_resumePoint, CBookmark::RESUME);
m_database.Close();
View
2 xbmc/video/VideoInfoTag.cpp
@@ -536,7 +536,7 @@ void CVideoInfoTag::ToSortable(SortItem& sortable)
sortable[FieldSubtitleLanguage] = m_streamDetails.GetSubtitleLanguage();
- sortable[FieldInProgress] = m_resumePoint.timeInSeconds > 0 && m_resumePoint.totalTimeInSeconds > 0;
+ sortable[FieldInProgress] = m_resumePoint.IsPartWay();
sortable[FieldDateAdded] = m_dateAdded.IsValid() ? m_dateAdded.GetAsDBDateTime() : StringUtils::EmptyString;
sortable[FieldMediaType] = DatabaseUtils::MediaTypeFromString(m_type);
}
View
43 xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -827,7 +827,7 @@ void CGUIWindowVideoBase::GetResumeItemOffset(const CFileItem *item, int& starto
if (!item->IsNFO() && !item->IsPlayList())
{
- if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0.0)
+ if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_resumePoint.IsSet())
{
startoffset = (int)(item->GetVideoInfoTag()->m_resumePoint.timeInSeconds*75);
partNumber = item->GetVideoInfoTag()->m_resumePoint.partNumber;
@@ -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 6791924

Please sign in to comment.