Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Partially watched fixes #956

Merged
merged 3 commits into from

2 participants

@pieh
Collaborator

This should fix ListItem.IsResumable and ListItem.PercentPlayed bugs.

First commit will fix ListItem.IsResumable infolabel returning true for items that we resumed playback and finished watching.

Second one add retrieving resume point from db by full path if we don't have fileId in VideoInfoTag (so it will fix our infolabels in file mode).

To fix those infolabels completely #955 needs resolving.

@pieh
Collaborator

updated commits

as this was month ago - here are old commits with our comments:
1. pieh@8bf5ca4
2. pieh@2c2ff0d

@pieh
Collaborator

Update:

  • fetching resume point for files is done in single query together with playcount for entire listing in LoadVideoInfo as suggested in DB optims PR
  • added fix for weird inconsistency: when we resume video and seek to very beginning of the video and immediately stop playback - then we don't remove/update resume bookmark from database, but we update resumePoint (timeInSeconds == 0.0f) in gui item which will remove IsResumable flag

Together with this commit Montellese@334ede8 we possibly could drop fetching resume point from thumbloader?

@jmarshallnz

Nice to see a pretty SQL - way easier to change later :)

@jmarshallnz
Owner

Looks good.

@pieh pieh was assigned
@pieh pieh merged commit 41acf92 into xbmc:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 xbmc/GUIInfoManager.cpp
@@ -3812,7 +3812,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)
+ if (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds > 0 && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0)
value = (int)(100 * ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds);
else
value = 0;
@@ -4299,7 +4299,7 @@ bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const
else if (condition == LISTITEM_IS_FOLDER)
return item->m_bIsFolder;
else if (condition == LISTITEM_IS_RESUMABLE)
- return (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds > 0);
+ return (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0);
return false;
}
View
4 xbmc/utils/SaveFileStateJob.h
@@ -62,9 +62,9 @@ bool CSaveFileStateJob::DoWork()
if (!m_item.HasVideoInfoTag() || m_item.GetVideoInfoTag()->m_resumePoint.timeInSeconds != m_bookmark.timeInSeconds)
{
- if (m_bookmark.timeInSeconds < 0.0f)
+ if (m_bookmark.timeInSeconds <= 0.0f)
videodatabase.ClearBookMarksOfFile(progressTrackingFile, CBookmark::RESUME);
- else if (m_bookmark.timeInSeconds > 0.0f)
+ else
videodatabase.AddBookMarkToFile(progressTrackingFile, m_bookmark, CBookmark::RESUME);
if (m_item.HasVideoInfoTag())
m_item.GetVideoInfoTag()->m_resumePoint = m_bookmark;
View
15 xbmc/video/VideoDatabase.cpp
@@ -3961,7 +3961,15 @@ bool CVideoDatabase::GetPlayCounts(const CStdString &strPath, CFileItemList &ite
if (NULL == m_pDS.get()) return false;
// TODO: also test a single query for the above and below
- CStdString sql = PrepareSQL("select strFilename,playCount from files where idPath=%i", pathID);
+ CStdString sql = PrepareSQL(
+ "SELECT"
+ " files.strFilename, files.playCount,"
+ " bookmark.timeInSeconds, bookmark.totalTimeInSeconds "
+ "FROM files"
+ " LEFT JOIN bookmark ON"
+ " files.idFile = bookmark.idFile AND bookmark.type = %i"
+ " WHERE files.idPath=%i", (int)CBookmark::RESUME, pathID);
+
if (RunQuery(sql) <= 0)
return false;
@@ -3972,7 +3980,12 @@ bool CVideoDatabase::GetPlayCounts(const CStdString &strPath, CFileItemList &ite
ConstructPath(path, strPath, m_pDS->fv(0).get_asString());
CFileItemPtr item = items.Get(path);
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;
+ }
m_pDS->next();
}
return true;
View
2  xbmc/video/VideoDatabase.h
@@ -396,7 +396,7 @@ class CVideoDatabase : public CDatabase
*/
void UpdateLastPlayed(const CFileItem &item);
- /*! \brief Get the playcount of a list of items
+ /*! \brief Get the playcount and resume point of a list of items
\param path the path to fetch videos from
\param items CFileItemList to fetch the playcounts for
\sa GetPlayCount, SetPlayCount, IncrementPlayCount
Something went wrong with that request. Please try again.