diff options
author | ace20022 <ace20022@ymail.com> | 2013-04-25 14:57:17 +0200 |
---|---|---|
committer | ace20022 <ace20022@ymail.com> | 2016-03-11 09:19:13 +0100 |
commit | 351143a7f74298dbbe0b1e7f8c06ae150f17efb1 (patch) | |
tree | b7553a447048ba626eeeea291e9ec58c9b843353 | |
parent | ca9fecc0fa095e542eb3c9b14d1fb7ccce32ff27 (diff) |
[Util] Add method to scan for external audio files.
-rw-r--r-- | xbmc/Util.cpp | 23 | ||||
-rw-r--r-- | xbmc/Util.h | 6 |
2 files changed, 29 insertions, 0 deletions
diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index b23bcc36a9..75f90b1850 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -2145,6 +2145,29 @@ std::string CUtil::GetVobSubIdxFromSub(const std::string& vobSub) return std::string(); } + +void CUtil::ScanForExternalAudio(const std::string& videoPath, std::vector<std::string>& vecAudio) +{ + CFileItem item(videoPath, false); + if ( item.IsInternetStream() + || item.IsPlayList() + || item.IsLiveTV() + || !item.IsVideo()) + return; + + std::string strBasePath; + std::string strAudio; + + GetVideoBasePathAndFileName(videoPath, strBasePath, strAudio); + + CFileItemList items; + const std::vector<std::string> common_sub_dirs = { "audio", "tracks"}; + GetItemsToScan(strBasePath, g_advancedSettings.GetMusicExtensions(), common_sub_dirs, items); + + std::vector<std::string> exts = StringUtils::Split(g_advancedSettings.GetMusicExtensions(), "|"); + ScanPathsForAssociatedItems(strAudio, items, exts, vecAudio); +} + bool CUtil::CanBindPrivileged() { #ifdef TARGET_POSIX diff --git a/xbmc/Util.h b/xbmc/Util.h index 2e14e121f1..d6c3fb3441 100644 --- a/xbmc/Util.h +++ b/xbmc/Util.h @@ -88,6 +88,12 @@ public: static bool IsVobSub(const std::vector<std::string>& vecSubtitles, const std::string& strSubPath); static std::string GetVobSubSubFromIdx(const std::string& vobSubIdx); static std::string GetVobSubIdxFromSub(const std::string& vobSub); + + /** \brief Retrieves paths of external audio files for a given video. + * \param[in] videoPath The full path of the video file. + * \param[out] vecAudio A vector containing the full paths of all found external audio files. + */ + static void ScanForExternalAudio(const std::string& videoPath, std::vector<std::string>& vecAudio); static int64_t ToInt64(uint32_t high, uint32_t low); static std::string GetNextFilename(const std::string &fn_template, int max); static std::string GetNextPathname(const std::string &path_template, int max); |