本文整理汇总了C++中CFileItemPtr::GetURL方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::GetURL方法的具体用法?C++ CFileItemPtr::GetURL怎么用?C++ CFileItemPtr::GetURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemPtr
的用法示例。
在下文中一共展示了CFileItemPtr::GetURL方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPlaylistByName
std::string CSmartPlaylistDirectory::GetPlaylistByName(const std::string& name, const std::string& playlistType)
{
CFileItemList list;
bool filesExist = false;
if (CSmartPlaylist::IsMusicType(playlistType))
filesExist = CDirectory::GetDirectory("special://musicplaylists/", list, ".xsp", false);
else // all others are video
filesExist = CDirectory::GetDirectory("special://videoplaylists/", list, ".xsp", false);
if (filesExist)
{
for (int i = 0; i < list.Size(); i++)
{
CFileItemPtr item = list[i];
CSmartPlaylist playlist;
if (playlist.OpenAndReadName(item->GetURL()))
{
if (StringUtils::EqualsNoCase(playlist.GetName(), name))
return item->GetPath();
}
}
for (int i = 0; i < list.Size(); i++)
{ // check based on filename
CFileItemPtr item = list[i];
if (URIUtils::GetFileName(item->GetPath()) == name)
{ // found :)
return item->GetPath();
}
}
}
return "";
}
示例2: OnClick
bool CGUIWindowPictures::OnClick(int iItem)
{
if ( iItem < 0 || iItem >= (int)m_vecItems->Size() ) return true;
CFileItemPtr pItem = m_vecItems->Get(iItem);
if (pItem->IsCBZ() || pItem->IsCBR())
{
CURL pathToUrl;
if (pItem->IsCBZ())
pathToUrl = URIUtils::CreateArchivePath("zip", pItem->GetURL(), "");
else
pathToUrl = URIUtils::CreateArchivePath("rar", pItem->GetURL(), "");
OnShowPictureRecursive(pathToUrl.Get());
return true;
}
else if (CGUIMediaWindow::OnClick(iItem))
return true;
return false;
}
示例3: GetDirectory
bool CDirectory::GetDirectory(const CURL& url, CFileItemList &items, const CHints &hints, bool allowThreads)
{
try
{
CURL realURL = URIUtils::SubstitutePath(url);
std::shared_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL));
if (!pDirectory.get())
return false;
// check our cache for this path
if (g_directoryCache.GetDirectory(realURL.Get(), items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE))
items.SetURL(url);
else
{
// need to clear the cache (in case the directory fetch fails)
// and (re)fetch the folder
if (!(hints.flags & DIR_FLAG_BYPASS_CACHE))
g_directoryCache.ClearDirectory(realURL.Get());
pDirectory->SetFlags(hints.flags);
bool result = false, cancel = false;
while (!result && !cancel)
{
const std::string pathToUrl(url.Get());
if (g_application.IsCurrentThread() && allowThreads && !URIUtils::IsSpecial(pathToUrl))
{
CSingleExit ex(g_graphicsContext);
CGetDirectory get(pDirectory, realURL, url);
if(!get.Wait(TIME_TO_BUSY_DIALOG))
{
CGUIDialogBusy* dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY);
if (dialog)
{
dialog->Open();
while(!get.Wait(10))
{
CSingleLock lock(g_graphicsContext);
// update progress
float progress = pDirectory->GetProgress();
if (progress > 0)
dialog->SetProgress(progress);
if (dialog->IsCanceled())
{
cancel = true;
pDirectory->CancelDirectory();
break;
}
lock.Leave(); // prevent an occasional deadlock on exit
g_windowManager.ProcessRenderLoop(false);
}
dialog->Close();
}
}
result = get.GetDirectory(items);
}
else
{
items.SetURL(url);
result = pDirectory->GetDirectory(realURL, items);
}
if (!result)
{
if (!cancel && g_application.IsCurrentThread() && pDirectory->ProcessRequirements())
continue;
CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, url.GetRedacted().c_str());
return false;
}
}
// cache the directory, if necessary
if (!(hints.flags & DIR_FLAG_BYPASS_CACHE))
g_directoryCache.SetDirectory(realURL.Get(), items, pDirectory->GetCacheType(url));
}
// now filter for allowed files
if (!pDirectory->AllowAll())
{
pDirectory->SetMask(hints.mask);
for (int i = 0; i < items.Size(); ++i)
{
CFileItemPtr item = items[i];
if (!item->m_bIsFolder && !pDirectory->IsAllowed(item->GetURL()))
{
items.Remove(i);
i--; // don't confuse loop
}
}
}
// filter hidden files
// TODO: we shouldn't be checking the gui setting here, callers should use getHidden instead
if (!CSettings::Get().GetBool("filelists.showhidden") && !(hints.flags & DIR_FLAG_GET_HIDDEN))
{
//.........这里部分代码省略.........
示例4: RunDisc
//.........这里部分代码省略.........
&& (bypassSettings))
{
bPlaying = true;
std::string strExec = StringUtils::Format("RecursiveSlideShow(%s)", pItem->GetPath().c_str());
CBuiltins::Execute(strExec);
return true;
}
*/
}
}
}
// check video first
if (!nAddedToPlaylist && !bPlaying && (bypassSettings || CServiceBroker::GetSettings().GetBool(CSettings::SETTING_DVDS_AUTORUN)))
{
// stack video files
CFileItemList tempItems;
tempItems.Append(vecItems);
if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MYVIDEOS_STACKVIDEOS))
tempItems.Stack();
CFileItemList itemlist;
for (int i = 0; i < tempItems.Size(); i++)
{
CFileItemPtr pItem = tempItems[i];
if (!pItem->m_bIsFolder && pItem->IsVideo())
{
bPlaying = true;
if (pItem->IsStack())
{
//! @todo remove this once the app/player is capable of handling stacks immediately
CStackDirectory dir;
CFileItemList items;
dir.GetDirectory(pItem->GetURL(), items);
itemlist.Append(items);
}
else
itemlist.Add(pItem);
}
}
if (itemlist.Size())
{
if (!bAllowVideo)
{
if (!bypassSettings)
return false;
if (!g_passwordManager.IsMasterLockUnlocked(true))
return false;
}
CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST_VIDEO);
CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST_VIDEO, itemlist);
CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST_VIDEO);
CServiceBroker::GetPlaylistPlayer().Play(0, "");
}
}
// then music
if (!bPlaying && (bypassSettings || CServiceBroker::GetSettings().GetInt(CSettings::SETTING_AUDIOCDS_AUTOACTION) == AUTOCD_PLAY) && bAllowMusic)
{
for (int i = 0; i < vecItems.Size(); i++)
{
CFileItemPtr pItem = vecItems[i];
if (!pItem->m_bIsFolder && pItem->IsAudio())
{
nAddedToPlaylist++;
CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST_MUSIC, pItem);
示例5: OnClick
void CGUIWindowFileManager::OnClick(int iList, int iItem)
{
if ( iList < 0 || iList >= 2) return ;
if ( iItem < 0 || iItem >= m_vecItems[iList]->Size() ) return ;
CFileItemPtr pItem = m_vecItems[iList]->Get(iItem);
if (pItem->GetPath() == "add" && pItem->GetLabel() == g_localizeStrings.Get(1026)) // 'add source button' in empty root
{
if (CGUIDialogMediaSource::ShowAndAddMediaSource("files"))
{
m_rootDir.SetSources(*CMediaSourceSettings::Get().GetSources("files"));
Update(0,m_Directory[0]->GetPath());
Update(1,m_Directory[1]->GetPath());
}
return;
}
if (!pItem->m_bIsFolder && pItem->IsFileFolder(EFILEFOLDER_MASK_ALL))
{
XFILE::IFileDirectory *pFileDirectory = NULL;
pFileDirectory = XFILE::CFileDirectoryFactory::Create(pItem->GetURL(), pItem.get(), "");
if(pFileDirectory)
pItem->m_bIsFolder = true;
else if(pItem->m_bIsFolder)
pItem->m_bIsFolder = false;
delete pFileDirectory;
}
if (pItem->m_bIsFolder)
{
// save path + drive type because of the possible refresh
CStdString strPath = pItem->GetPath();
int iDriveType = pItem->m_iDriveType;
if ( pItem->m_bIsShareOrDrive )
{
if ( !g_passwordManager.IsItemUnlocked( pItem.get(), "files" ) )
{
Refresh();
return ;
}
if ( !HaveDiscOrConnection( strPath, iDriveType ) )
return ;
}
if (!Update(iList, strPath))
ShowShareErrorMessage(pItem.get());
}
else if (pItem->IsZIP() || pItem->IsCBZ()) // mount zip archive
{
CURL pathToUrl = URIUtils::CreateArchivePath("zip", pItem->GetURL(), "");
Update(iList, pathToUrl.Get());
}
else if (pItem->IsRAR() || pItem->IsCBR())
{
CURL pathToUrl = URIUtils::CreateArchivePath("rar", pItem->GetURL(), "");
Update(iList, pathToUrl.Get());
}
else
{
OnStart(pItem.get());
return ;
}
// UpdateButtons();
}
示例6: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const std::string &strBaseDir /* = "" */, bool filter /* = false */)
{
bool success = false, success2 = false;
std::vector<std::string> virtualFolders;
SortDescription sorting;
sorting.limitEnd = playlist.GetLimit();
sorting.sortBy = playlist.GetOrder();
sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending;
sorting.sortAttributes = playlist.GetOrderAttributes();
if (CSettings::Get().GetBool("filelists.ignorethewhensorting"))
sorting.sortAttributes = (SortAttribute)(sorting.sortAttributes | SortAttributeIgnoreArticle);
items.SetSortIgnoreFolders((sorting.sortAttributes & SortAttributeIgnoreFolders) == SortAttributeIgnoreFolders);
std::string option = !filter ? "xsp" : "filter";
const std::string& group = playlist.GetGroup();
bool isGrouped = !group.empty() && !StringUtils::EqualsNoCase(group, "none") && !playlist.IsGroupMixed();
// get all virtual folders and add them to the item list
playlist.GetVirtualFolders(virtualFolders);
for (std::vector<std::string>::const_iterator virtualFolder = virtualFolders.begin(); virtualFolder != virtualFolders.end(); virtualFolder++)
{
CFileItemPtr pItem = CFileItemPtr(new CFileItem(*virtualFolder, true));
IFileDirectory *dir = CFileDirectoryFactory::Create(pItem->GetURL(), pItem.get());
if (dir != NULL)
{
pItem->SetSpecialSort(SortSpecialOnTop);
items.Add(pItem);
delete dir;
}
}
if (playlist.GetType() == "movies" ||
playlist.GetType() == "tvshows" ||
playlist.GetType() == "episodes")
{
CVideoDatabase db;
if (db.Open())
{
MediaType mediaType = MediaTypes::FromString(playlist.GetType());
std::string baseDir = strBaseDir;
if (strBaseDir.empty())
{
if (mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode)
baseDir = "videodb://tvshows/";
else if (mediaType == MediaTypeMovie)
baseDir = "videodb://movies/";
else
return false;
if (!isGrouped)
baseDir += "titles";
else
baseDir += group;
URIUtils::AddSlashAtEnd(baseDir);
if (mediaType == MediaTypeEpisode)
baseDir += "-1/-1/";
}
CVideoDbUrl videoUrl;
if (!videoUrl.FromString(baseDir))
return false;
// store the smartplaylist as JSON in the URL as well
std::string xsp;
if (!playlist.IsEmpty(filter))
{
if (!playlist.SaveAsJson(xsp, !filter))
return false;
}
if (!xsp.empty())
videoUrl.AddOption(option, xsp);
else
videoUrl.RemoveOption(option);
CDatabase::Filter dbfilter;
success = db.GetItems(videoUrl.ToString(), items, dbfilter, sorting);
db.Close();
// if we retrieve a list of episodes and we didn't receive
// a pre-defined base path, we need to fix it
if (strBaseDir.empty() && mediaType == MediaTypeEpisode && !isGrouped)
videoUrl.AppendPath("-1/-1/");
items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString());
}
}
else if (playlist.IsMusicType() || playlist.GetType().empty())
{
CMusicDatabase db;
if (db.Open())
{
CSmartPlaylist plist(playlist);
if (playlist.GetType() == "mixed" || playlist.GetType().empty())
plist.SetType("songs");
MediaType mediaType = MediaTypes::FromString(plist.GetType());
//.........这里部分代码省略.........