Skip to content

Commit

Permalink
Merge pull request #3644 from Voyager1/dvd-folder-nopl
Browse files Browse the repository at this point in the history
Playback of a DVD as files in a folder should not create a playlist
  • Loading branch information
jmarshallnz committed Nov 20, 2013
2 parents d2b862b + d340cc4 commit dc6d3b2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 30 deletions.
65 changes: 36 additions & 29 deletions xbmc/FileItem.cpp
Expand Up @@ -1543,6 +1543,40 @@ void CFileItem::SetFromSong(const CSong &song)
FillInMimeType(false);
}

std::string CFileItem::GetOpticalMediaPath() const
{
std::string path;
std::string dvdPath;
path = URIUtils::AddFileToFolder(GetPath(), "VIDEO_TS.IFO");
if (CFile::Exists(path))
dvdPath = path;
else
{
dvdPath = URIUtils::AddFileToFolder(GetPath(), "VIDEO_TS");
path = URIUtils::AddFileToFolder(dvdPath, "VIDEO_TS.IFO");
dvdPath.clear();
if (CFile::Exists(path))
dvdPath = path;
}
#ifdef HAVE_LIBBLURAY
if (dvdPath.empty())
{
path = URIUtils::AddFileToFolder(GetPath(), "index.bdmv");
if (CFile::Exists(path))
dvdPath = path;
else
{
dvdPath = URIUtils::AddFileToFolder(GetPath(), "BDMV");
path = URIUtils::AddFileToFolder(dvdPath, "index.bdmv");
dvdPath.clear();
if (CFile::Exists(path))
dvdPath = path;
}
}
#endif
return dvdPath;
}

/////////////////////////////////////////////////////////////////////////////////
/////
///// CFileItemList
Expand Down Expand Up @@ -2359,35 +2393,8 @@ void CFileItemList::StackFolders()
// check for dvd folders
if (!bMatch)
{
CStdString path;
CStdString dvdPath;
path = URIUtils::AddFileToFolder(item->GetPath(), "VIDEO_TS.IFO");
if (CFile::Exists(path))
dvdPath = path;
else
{
dvdPath = URIUtils::AddFileToFolder(item->GetPath(), "VIDEO_TS");
path = URIUtils::AddFileToFolder(dvdPath, "VIDEO_TS.IFO");
dvdPath.clear();
if (CFile::Exists(path))
dvdPath = path;
}
#ifdef HAVE_LIBBLURAY
if (dvdPath.empty())
{
path = URIUtils::AddFileToFolder(item->GetPath(), "index.bdmv");
if (CFile::Exists(path))
dvdPath = path;
else
{
dvdPath = URIUtils::AddFileToFolder(item->GetPath(), "BDMV");
path = URIUtils::AddFileToFolder(dvdPath, "index.bdmv");
dvdPath.clear();
if (CFile::Exists(path))
dvdPath = path;
}
}
#endif
std::string dvdPath = item->GetOpticalMediaPath();

if (!dvdPath.empty())
{
// NOTE: should this be done for the CD# folders too?
Expand Down
8 changes: 8 additions & 0 deletions xbmc/FileItem.h
Expand Up @@ -119,6 +119,14 @@ class CFileItem :

bool Exists(bool bUseCache = true) const;

/*!
\brief Check whether an item is an optical media folder or its parent.
This will return the non-empty path to the playable entry point of the media
one or two levels down (VIDEO_TS.IFO for DVDs or index.bdmv for BDs).
The returned path will be empty if folder does not meet this criterion.
\return non-empty string if item is optical media folder, empty otherwise.
*/
std::string GetOpticalMediaPath() const;
/*!
\brief Check whether an item is a video item. Note that this returns true for
anything with a video info tag, so that may include eg. folders.
Expand Down
9 changes: 9 additions & 0 deletions xbmc/video/windows/GUIWindowVideoBase.cpp
Expand Up @@ -755,6 +755,15 @@ void CGUIWindowVideoBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem
if (pItem->IsParentFolder())
return;

// check if it's a folder with dvd or bluray files, then just add the relevant file
std::string mediapath(pItem->GetOpticalMediaPath());
if (!mediapath.empty())
{
CFileItemPtr item(new CFileItem(mediapath, false));
queuedItems.Add(item);
return;
}

// Check if we add a locked share
if ( pItem->m_bIsShareOrDrive )
{
Expand Down
17 changes: 16 additions & 1 deletion xbmc/windows/GUIMediaWindow.cpp
Expand Up @@ -1336,14 +1336,29 @@ bool CGUIMediaWindow::OnPlayAndQueueMedia(const CFileItemPtr &item)
g_playlistPlayer.ClearPlaylist(iPlaylist);
g_playlistPlayer.Reset();
int mediaToPlay = 0;

// first try to find mainDVD file (VIDEO_TS.IFO).
// If we find this we should not allow to queue VOB files
std::string mainDVD;
for (int i = 0; i < m_vecItems->Size(); i++)
{
std::string path = URIUtils::GetFileName(m_vecItems->Get(i)->GetPath());
if (StringUtils::EqualsNoCase(path, "VIDEO_TS.IFO"))
{
mainDVD = path;
break;
}
}

// now queue...
for ( int i = 0; i < m_vecItems->Size(); i++ )
{
CFileItemPtr nItem = m_vecItems->Get(i);

if (nItem->m_bIsFolder)
continue;

if (!nItem->IsPlayList() && !nItem->IsZIP() && !nItem->IsRAR())
if (!nItem->IsPlayList() && !nItem->IsZIP() && !nItem->IsRAR() && (!nItem->IsDVDFile() || (URIUtils::GetFileName(nItem->GetPath()) == mainDVD)))
g_playlistPlayer.Add(iPlaylist, nItem);

if (item->IsSamePath(nItem.get()))
Expand Down

0 comments on commit dc6d3b2

Please sign in to comment.