Skip to content

Commit

Permalink
Resume DVDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Voyager-xbmc committed May 1, 2011
1 parent 67e7b08 commit f7fbe3c
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 28 deletions.
5 changes: 4 additions & 1 deletion xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3666,7 +3666,10 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart)
{
options.starttime = 0.0f;
CBookmark bookmark;
if(dbs.GetResumeBookMark(item.m_strPath, bookmark))
CStdString path = item.m_strPath;
if (item.IsDVD())
path = item.GetVideoInfoTag()->m_strFileNameAndPath;
if(dbs.GetResumeBookMark(path, bookmark))
{
options.starttime = bookmark.timeInSeconds;
options.state = bookmark.playerState;
Expand Down
20 changes: 10 additions & 10 deletions xbmc/Autorun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CAutorun::CAutorun()
CAutorun::~CAutorun()
{}

void CAutorun::ExecuteAutorun( bool bypassSettings, bool ignoreplaying )
void CAutorun::ExecuteAutorun( bool bypassSettings, bool ignoreplaying, bool restart )
{
if ((!ignoreplaying && (g_application.IsPlayingAudio() || g_application.IsPlayingVideo() || g_windowManager.HasModalDialog())) || g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN)
return ;
Expand All @@ -78,7 +78,7 @@ void CAutorun::ExecuteAutorun( bool bypassSettings, bool ignoreplaying )
}
else
{
RunMedia(bypassSettings);
RunMedia(bypassSettings, restart);
}
}

Expand All @@ -99,7 +99,7 @@ void CAutorun::RunCdda()
g_playlistPlayer.Play();
}

void CAutorun::RunMedia(bool bypassSettings)
void CAutorun::RunMedia(bool bypassSettings, bool restart)
{
if ( !bypassSettings && !g_guiSettings.GetBool("audiocds.autorun") && !g_guiSettings.GetBool("dvds.autorun"))
return ;
Expand All @@ -108,7 +108,7 @@ void CAutorun::RunMedia(bool bypassSettings)
int nAddedToPlaylist = 0;
#ifdef _WIN32
auto_ptr<IDirectory> pDir ( CFactoryDirectory::Create( g_mediaManager.TranslateDevicePath("") ));
bool bPlaying = RunDisc(pDir.get(), g_mediaManager.TranslateDevicePath(""), nAddedToPlaylist, true, bypassSettings);
bool bPlaying = RunDisc(pDir.get(), g_mediaManager.TranslateDevicePath(""), nAddedToPlaylist, true, bypassSettings, restart);
#else
CCdInfo* pInfo = g_mediaManager.GetCdInfo();

Expand Down Expand Up @@ -140,7 +140,7 @@ void CAutorun::RunMedia(bool bypassSettings)
/**
* This method tries to determine what type of disc is located in the given drive and starts to play the content appropriately.
*/
bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */)
bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings /* = false */, bool restart /* = false */)
{
bool bPlaying(false);
CFileItemList vecItems;
Expand Down Expand Up @@ -178,7 +178,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
if (pItem->m_strPath.Find( "VIDEO_TS" ) != -1 && bAllowVideo
&& (bypassSettings || g_guiSettings.GetBool("dvds.autorun")))
{
CUtil::PlayDVD();
CUtil::PlayDVD("dvd", restart);
bPlaying = true;
return true;
}
Expand All @@ -189,7 +189,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
if (pItem->m_strPath.Find( "BDMV" ) != -1 && bAllowVideo
&& (bypassSettings || g_guiSettings.GetBool("dvds.autorun")))
{
CUtil::PlayDVD("bd");
CUtil::PlayDVD("bd", restart);
bPlaying = true;
return true;
}
Expand Down Expand Up @@ -320,7 +320,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
{
if (pItem->m_strPath != "." && pItem->m_strPath != ".." )
{
if (RunDisc(pDir, pItem->m_strPath, nAddedToPlaylist, false, bypassSettings))
if (RunDisc(pDir, pItem->m_strPath, nAddedToPlaylist, false, bypassSettings, restart))
{
bPlaying = true;
break;
Expand Down Expand Up @@ -365,9 +365,9 @@ bool CAutorun::IsEnabled() const
return m_bEnable;
}

bool CAutorun::PlayDisc()
bool CAutorun::PlayDisc(bool restart)
{
ExecuteAutorun(true,true);
ExecuteAutorun(true,true, restart);
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions xbmc/Autorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ class CAutorun
public:
CAutorun();
virtual ~CAutorun();
static bool PlayDisc();
static bool PlayDisc(bool restart = false);
bool IsEnabled() const;
void Enable();
void Disable();
void HandleAutorun();
static void ExecuteAutorun(bool bypassSettings = false, bool ignoreplaying=false);
static void ExecuteAutorun(bool bypassSettings = false, bool ignoreplaying = false, bool restart = false);
protected:
static void RunCdda();
static void RunMedia(bool bypassSettings = false);
static bool RunDisc(XFILE::IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings = false);
static void RunMedia(bool bypassSettings, bool restart);
static bool RunDisc(XFILE::IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings, bool restart);
bool m_bEnable;
};
}
Expand Down
5 changes: 5 additions & 0 deletions xbmc/FileItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ CFileItem::CFileItem(const CMediaSource& share)
m_iDriveType = share.m_iDriveType;
m_strThumbnailImage = share.m_strThumbnailImage;
SetLabelPreformated(true);
if (IsDVD())
{
GetVideoInfoTag()->m_strFileNameAndPath = "removable://";
GetVideoInfoTag()->m_strFileNameAndPath += share.strStatus; // share.strStatus contains disc volume label
}
}

CFileItem::~CFileItem(void)
Expand Down
8 changes: 6 additions & 2 deletions xbmc/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include "cores/dvdplayer/DVDSubtitles/DVDSubtitleTagSami.h"
#include "cores/dvdplayer/DVDSubtitles/DVDSubtitleStream.h"
#include "windowing/WindowingFactory.h"
#include "video/VideoInfoTag.h"

using namespace std;
using namespace XFILE;
Expand Down Expand Up @@ -755,7 +756,7 @@ bool CUtil::ThumbCached(const CStdString& strFileName)
return CThumbnailCache::GetThumbnailCache()->IsCached(strFileName);
}

void CUtil::PlayDVD(const CStdString& strProtocol)
void CUtil::PlayDVD(const CStdString& strProtocol, bool restart)
{
#if defined(HAS_DVDPLAYER) && defined(HAS_DVD_DRIVE)
CIoSupport::Dismount("Cdrom0");
Expand All @@ -764,7 +765,10 @@ void CUtil::PlayDVD(const CStdString& strProtocol)
strPath.Format("%s://1", strProtocol.c_str());
CFileItem item(strPath, false);
item.SetLabel(g_mediaManager.GetDiskLabel());
g_application.PlayFile(item);
item.GetVideoInfoTag()->m_strFileNameAndPath = "removable://"; // need to put volume label for resume point in videoInfoTag
item.GetVideoInfoTag()->m_strFileNameAndPath += g_mediaManager.GetDiskLabel();
if (!restart) item.m_lStartOffset = STARTOFFSET_RESUME;
g_application.PlayFile(item, restart);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion xbmc/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CUtil
static bool ThumbCached(const CStdString& strFileName);
static void ThumbCacheAdd(const CStdString& strFileName, bool bFileExists);
static void ThumbCacheClear();
static void PlayDVD(const CStdString& strProtocol="dvd");
static void PlayDVD(const CStdString& strProtocol = "dvd", bool restart = false);
static CStdString GetNextFilename(const CStdString &fn_template, int max);
static CStdString GetNextPathname(const CStdString &path_template, int max);
static void TakeScreenshot();
Expand Down
13 changes: 11 additions & 2 deletions xbmc/dialogs/GUIDialogContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "settings/Settings.h"
#include "guilib/LocalizeStrings.h"
#include "TextureCache.h"
#include "video/windows/GUIWindowVideoBase.h"

#ifdef _WIN32
#include "WIN32Util.h"
Expand Down Expand Up @@ -217,8 +218,14 @@ void CGUIDialogContextMenu::GetContextButtons(const CStdString &type, const CFil
if (item->IsDVD() || item->IsCDDA())
{
// We need to check if there is a detected is inserted!
if ( g_mediaManager.IsDiscInDrive() )
if ( g_mediaManager.IsDiscInDrive() )
{
buttons.Add(CONTEXT_BUTTON_PLAY_DISC, 341); // Play CD/DVD!
if (CGUIWindowVideoBase::GetResumeItemOffset(item.get()) > 0)
{
buttons.Add(CONTEXT_BUTTON_RESUME_DISC, CGUIWindowVideoBase::GetResumeString(*(item.get()))); // Resume Disc
}
}
buttons.Add(CONTEXT_BUTTON_EJECT_DISC, 13391); // Eject/Load CD/DVD!
}
else // Must be HDD
Expand Down Expand Up @@ -312,6 +319,9 @@ bool CGUIDialogContextMenu::OnContextButton(const CStdString &type, const CFileI

#ifdef HAS_DVD_DRIVE
case CONTEXT_BUTTON_PLAY_DISC:
return MEDIA_DETECT::CAutorun::PlayDisc(true); // restart

case CONTEXT_BUTTON_RESUME_DISC:
return MEDIA_DETECT::CAutorun::PlayDisc();

case CONTEXT_BUTTON_EJECT_DISC:
Expand Down Expand Up @@ -693,4 +703,3 @@ void CGUIDialogContextMenu::PositionAtCurrentFocus()
// no control to center at, so just center the window
CenterWindow();
}

1 change: 1 addition & 0 deletions xbmc/dialogs/GUIDialogContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0,
CONTEXT_BUTTON_SETTINGS,
CONTEXT_BUTTON_GOTO_ROOT,
CONTEXT_BUTTON_PLAY_DISC,
CONTEXT_BUTTON_RESUME_DISC,
CONTEXT_BUTTON_RIP_CD,
CONTEXT_BUTTON_RIP_TRACK,
CONTEXT_BUTTON_EJECT_DISC,
Expand Down
3 changes: 3 additions & 0 deletions xbmc/utils/SaveFileStateJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ bool CSaveFileStateJob::DoWork()
{
CStdString progressTrackingFile = m_item.m_strPath;

if (m_item.IsDVD())
progressTrackingFile = m_item.GetVideoInfoTag()->m_strFileNameAndPath; // this variable contains removable:// suffixed by disc label

if (progressTrackingFile != "")
{
if (m_item.IsVideo())
Expand Down
7 changes: 4 additions & 3 deletions xbmc/video/windows/GUIWindowVideoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ int CGUIWindowVideoBase::GetResumeItemOffset(const CFileItem *item)
{
CBookmark bookmark;
CStdString strPath = item->m_strPath;
if (item->IsVideoDb() && item->HasVideoInfoTag())
if ((item->IsVideoDb() || item->IsDVD()) && item->HasVideoInfoTag())
strPath = item->GetVideoInfoTag()->m_strFileNameAndPath;

if (db.GetResumeBookMark(strPath, bookmark))
Expand Down Expand Up @@ -990,7 +990,7 @@ CStdString CGUIWindowVideoBase::GetResumeString(CFileItem item)
{
CBookmark bookmark;
CStdString itemPath(item.m_strPath);
if (item.IsVideoDb())
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(lrint(bookmark.timeInSeconds)).c_str());
Expand Down Expand Up @@ -1114,7 +1114,8 @@ void CGUIWindowVideoBase::GetContextButtons(int itemNumber, CContextButtons &but

// if autoresume is enabled then add restart video button
// check to see if the Resume Video button is applicable
if (GetResumeItemOffset(item.get()) > 0)
// only if the video is NOT a DVD (in that case the resume button will be added by CGUIDialogContextMenu::GetContextButtons)
if (!item->IsDVD() && GetResumeItemOffset(item.get()) > 0)
{
buttons.Add(CONTEXT_BUTTON_RESUME_ITEM, GetResumeString(*(item.get()))); // Resume Video
}
Expand Down
12 changes: 7 additions & 5 deletions xbmc/video/windows/GUIWindowVideoBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObse

static void OnAssignContent(const CStdString &path, int iFound, ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings);

/*! \brief checks the database for a resume position and puts together a string
\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);

protected:
void OnScan(const CStdString& strPath, bool scanAll = false);
virtual void UpdateButtons();
Expand Down Expand Up @@ -92,11 +98,7 @@ class CGUIWindowVideoBase : public CGUIMediaWindow, public IBackgroundLoaderObse
\return true if the action is performed, false otherwise
*/
bool OnFileAction(int item, int action);
/*! \brief checks the database for a resume position and puts together a string
\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);

void OnRestartItem(int iItem);
bool OnResumeItem(int iItem);
void PlayItem(int iItem);
Expand Down

0 comments on commit f7fbe3c

Please sign in to comment.