本文整理汇总了C++中metadb_handle_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ metadb_handle_ptr类的具体用法?C++ metadb_handle_ptr怎么用?C++ metadb_handle_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了metadb_handle_ptr类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LRCTitleFormatCallback
std::wstring LyricSourceLRC::getSavePath(const metadb_handle_ptr &track)
{
std::string path = track->get_path();
std::wstring wpath = EncodingFunc::ToUTF16(path.substr(boost::find_last(path, "://").end() - path.begin()));
wpath = wpath.substr(0, wpath.find_last_of(L"."));
if(track->get_subsong_index() != 0)
wpath += boost::lexical_cast<std::wstring>(track->get_subsong_index());
wpath += L".lrc";
if(m_config["lrcsavepath"].length())
{
class LRCTitleFormatCallback : public main_thread_callback
{
private:
HANDLE m_event;
std::string *m_out;
const std::string &m_format;
const metadb_handle_ptr &m_track;
public:
LRCTitleFormatCallback(HANDLE event, std::string *out, const std::string &format, const metadb_handle_ptr &track) : m_event(event), m_format(format), m_out(out), m_track(track) {}
virtual void callback_run()
{
core_api::ensure_main_thread();
pfc::string8 out;
service_ptr_t<titleformat_object> script;
static_api_ptr_t<titleformat_compiler>()->compile(script, m_format.c_str());
m_track->format_title(NULL, out, script, NULL);
m_out->assign(out.get_ptr());
SetEvent(m_event);
}
};
std::wstring dirname = wpath.substr(0, wpath.find_last_of(L'\\') + 1);
std::wstring filename = wpath.substr(wpath.find_last_of(L"\\") + 1);
HANDLE event = CreateEvent(NULL, TRUE, FALSE, NULL);
std::string out;
std::string pathtmp = m_config["lrcsavepath"];
if(pathtmp.at(pathtmp.length() - 1) != '\\')
pathtmp += '\\';
service_ptr_t<LRCTitleFormatCallback> p_callback = new service_impl_t<LRCTitleFormatCallback>(event, &out, pathtmp, track);
static_api_ptr_t<main_thread_callback_manager>()->add_callback(p_callback);
p_callback.release();
WaitForSingleObject(event, INFINITE);
CloseHandle(event);
wpath = EncodingFunc::ToUTF16(out);
if(PathIsRelative(wpath.c_str()))
wpath = dirname + wpath;
if(GetFileAttributes(wpath.c_str()) & FILE_ATTRIBUTE_DIRECTORY && (GetLastError() != ERROR_FILE_NOT_FOUND && GetLastError() != ERROR_PATH_NOT_FOUND))
wpath += filename;
return wpath;
}
if(path.find_first_of("file://") == std::string::npos)
return std::wstring(L"");
if(path.find_first_of("unpack://") == std::string::npos)
return std::wstring(L"");
return wpath;
}
开发者ID:dlunch,项目名称:foo_alsong_lyric,代码行数:57,代码来源:LyricSourceLRC.cpp
示例2: update_metadata
void stream_encoders::update_metadata(metadb_handle_ptr p_track){
if(p_track!=0){
p_track->metadb_lock();
const file_info*p_info;
if(p_track->get_info_async_locked(p_info))
update_metadata(*p_info);
p_track->metadb_unlock();
}
}
开发者ID:danny8376,项目名称:foo_vorbisstreamer,代码行数:9,代码来源:Encoders.cpp
示例3: query_scale
audio_sample t_replaygain_config::query_scale(const metadb_handle_ptr & p_object) const
{
audio_sample rv = 1.0;
p_object->metadb_lock();
const file_info * info;
if (p_object->get_info_async_locked(info))
rv = query_scale(*info);
p_object->metadb_unlock();
return rv;
}
开发者ID:AICIDNN,项目名称:lastfm-desktop,代码行数:10,代码来源:replaygain.cpp
示例4: isTrackByArtist
inline bool isTrackByArtist(const std::string& artist, const metadb_handle_ptr& track)
{
// todo: ignore slight differences, e.g. in punctuation
service_ptr_t<metadb_info_container> outInfo;
if(track->get_async_info_ref(outInfo))
{
const file_info& fileInfo = outInfo->info();
for(t_size j = 0; j < fileInfo.meta_get_count_by_name("artist"); j++)
{
if(stricmp_utf8(fileInfo.meta_get("artist", j), artist.c_str()) == 0)
{
return true;
}
}
for(t_size j = 0; j < fileInfo.meta_get_count_by_name("album artist"); j++)
{
if(stricmp_utf8(fileInfo.meta_get("album artist", j), artist.c_str()) == 0)
{
return true;
}
}
}
return false;
}
开发者ID:hymerman,项目名称:foo_bestversion,代码行数:27,代码来源:BestVersion.cpp
示例5: playlist_get_item_handle
bool playlist_manager::playlist_get_item_handle(metadb_handle_ptr & p_out,t_size p_playlist,t_size p_item)
{
enum_items_callback_retrieve_item callback;
playlist_enum_items(p_playlist,callback,bit_array_one(p_item));
p_out = callback.get_item();
return p_out.is_valid();
}
开发者ID:Irwin1138,项目名称:foo_bestversion,代码行数:7,代码来源:playlist.cpp
示例6: doesTrackHaveSimilarTitle
bool doesTrackHaveSimilarTitle(const std::string& title, const metadb_handle_ptr& track)
{
// todo: ignore slight differences, e.g. in punctuation
service_ptr_t<metadb_info_container> outInfo;
if (!track->get_async_info_ref(outInfo))
{
return false;
}
const file_info& fileInfo = outInfo->info();
if(!fileInfo.meta_exists("title"))
{
return false;
}
const std::string fileTitle = fileInfo.meta_get("title", 0);
if(stricmp_utf8(fileTitle.c_str(), title.c_str()) == 0)
{
return true;
}
else if(fileTitlesMatchExcludingBracketsOnLhs(fileTitle, title))
{
return true;
}
return false;
}
开发者ID:hymerman,项目名称:foo_bestversion,代码行数:30,代码来源:BestVersion.cpp
示例7: format_filename
void create_directory_helper::format_filename(const metadb_handle_ptr & handle,titleformat_hook * p_hook,const char * spec,pfc::string8 & out)
{
pfc::string8 temp;
handle->format_title_legacy(p_hook,temp,spec,&titleformat_text_filter_impl_createdir());
temp.replace_char('/','\\');
temp.fix_filename_chars('_','\\');
out = temp;
}
开发者ID:Jorgorbia,项目名称:AltaCast,代码行数:8,代码来源:create_directory_helper.cpp
示例8: replaceTrackInActivePlaylist
void replaceTrackInActivePlaylist(const metadb_handle_ptr& trackToReplace, const metadb_handle_ptr& replacement)
{
t_size index = 0;
static_api_ptr_t<playlist_manager> pm;
if(!pm->activeplaylist_find_item(trackToReplace, index))
{
console::printf("Couldn't find track in active playlist to replace it: %s", trackToReplace->get_path());
return;
}
if(!pm->activeplaylist_replace_item(index, replacement))
{
console::printf("Couldn't replace track in active playlist: %s", trackToReplace->get_path());
return;
}
}
开发者ID:hymerman,项目名称:foo_bestversion,代码行数:17,代码来源:PlaylistGenerator.cpp
示例9: getTitle
std::string getTitle(metadb_handle_ptr track)
{
service_ptr_t<metadb_info_container> outInfo;
if(!track->get_async_info_ref(outInfo))
{
return "";
}
const file_info& fileInfo = outInfo->info();
const bool has_title_tag = fileInfo.meta_exists("title");
if(!has_title_tag)
{
return "";
}
const char* title = fileInfo.meta_get("title", 0);
return title;
}
开发者ID:hymerman,项目名称:foo_bestversion,代码行数:20,代码来源:BestVersion.cpp
示例10: getArtist
std::string getArtist(metadb_handle_ptr track)
{
service_ptr_t<metadb_info_container> outInfo;
if(!track->get_async_info_ref(outInfo))
{
return "";
}
const file_info& fileInfo = outInfo->info();
const bool has_artist_tag = fileInfo.meta_exists("artist");
const bool has_album_artist_tag = fileInfo.meta_exists("album artist");
if(!(has_artist_tag || has_album_artist_tag))
{
return "";
}
const char* artistName = has_artist_tag ? fileInfo.meta_get("artist", 0) : fileInfo.meta_get("album artist", 0);
return artistName;
}
开发者ID:hymerman,项目名称:foo_bestversion,代码行数:21,代码来源:BestVersion.cpp
示例11: get_track_info
pfc::string8 get_track_info(const metadb_handle_ptr track, abort_callback &p_abort) {
pfc::string8 api_key = "803d3cbea0bbe50c61ab81c4fe5fe20f";
pfc::string8 url, page, artist_enc, title_enc;
const file_info *file_info;
const char *artist;
const char *title;
bool meta;
static_api_ptr_t<metadb> db;
db->database_lock();
meta = track->get_info_async_locked(file_info);
db->database_unlock();
if (meta && file_info->meta_exists("artist") &&
file_info->meta_exists("title")) {
artist = file_info->meta_get("artist", 0);
title = file_info->meta_get("title", 0);
} else {
throw pfc::exception("Unknown track");
}
pfc::urlEncode(artist_enc, artist);
pfc::urlEncode(title_enc, title);
url << "http://ws.audioscrobbler.com/2.0/?method=track.getInfo"
<< "&api_key=" << api_key << "&artist=" << artist_enc << "&track=" << title_enc;
console::print(url);
page = get_url(url, p_abort);
if (page.get_length() < 10) {
throw pfc::exception("Last.fm returned an empty page");
}
return page;
}
开发者ID:epsil,项目名称:foo_lastsort,代码行数:37,代码来源:foo_lastsort.cpp
示例12: print_location
void console::print_location(const metadb_handle_ptr & src)
{
print_location(src->get_location());
}
开发者ID:Irwin1138,项目名称:foo_bestversion,代码行数:4,代码来源:console.cpp
示例13: calculateTrackRating
float calculateTrackRating(const std::string& title, const metadb_handle_ptr& track)
{
service_ptr_t<metadb_info_container> outInfo;
if(!track->get_async_info_ref(outInfo))
{
// Don't pick it we can't get any info.
return -1.0f;
}
const file_info& fileInfo = outInfo->info();
if (!fileInfo.meta_exists("title"))
{
// Don't pick it if it doesn't have a title.
return -1.0f;
}
float totalRating = 0.0f;
const std::string fileTitle = fileInfo.meta_get("title", 0);
// Assume title is already roughly correct.
if(stricmp_utf8(fileTitle.c_str(), title.c_str()) == 0)
{
static const float ratingForExactTitleMatch = 2.0f;
totalRating += ratingForExactTitleMatch;
}
else
{
static const float ratingForTitleMatchWithBrackets = 1.0f;
totalRating += ratingForTitleMatchWithBrackets;
}
if(fileInfo.meta_exists("PLAY_COUNTER"))
{
const int playCount = atoi(fileInfo.meta_get("PLAY_COUNTER",0));
static const float lowPlayCount = 0.0f;
static const float highPlayCount = 10.0f;
static const float lowPlayCountRating = 0.0f;
static const float highPlayCountRating = 0.5f;
const float playCountRating = maths::map(static_cast<float>(playCount), lowPlayCount, highPlayCount, lowPlayCountRating, highPlayCountRating);
totalRating += playCountRating;
}
const auto bitrate = fileInfo.info_get_bitrate();
static const float lowBitrate = 0.0f;
static const float highBitrate = 1000.0f;
static const float lowBitrateRating = 0.0f;
static const float highBitrateRating = 2.0f;
const float bitrateRating = maths::map(static_cast<float>(bitrate), lowBitrate, highBitrate, lowBitrateRating, highBitrateRating);
totalRating += bitrateRating;
static const float releaseTypeWeighting = 3.0f;
float releaseTypeRating = 0.55f; // Default for if nothing is set; assume it's somewhere between a live album and a soundtrack.
if(fileInfo.meta_exists("musicbrainz album type") || fileInfo.meta_exists("releasetype"))
{
const std::string albumType = fileInfo.meta_exists("musicbrainz album type") ? fileInfo.meta_get("musicbrainz album type", 0) : fileInfo.meta_get("releasetype", 0);
if(albumType == "album")
{
releaseTypeRating = 1.0f;
}
else if(albumType == "single")
{
releaseTypeRating = 0.9f;
}
else if(albumType == "compilation")
{
releaseTypeRating = 0.8f;
}
else if(albumType == "ep")
{
releaseTypeRating = 0.7f;
}
else if(albumType == "soundtrack")
{
releaseTypeRating = 0.6f;
}
else if(albumType == "live")
{
releaseTypeRating = 0.5f;
}
else if(albumType == "other")
{
releaseTypeRating = 0.4f;
}
else if(albumType == "remix")
{
releaseTypeRating = 0.3f;
//.........这里部分代码省略.........
开发者ID:hymerman,项目名称:foo_bestversion,代码行数:101,代码来源:BestVersion.cpp
示例14: on_playback_new_track
void SmoothArtUIE::on_playback_new_track(metadb_handle_ptr p_track)
{
GetArt(p_track->get_path());
}
开发者ID:dhda,项目名称:foo_smoothart,代码行数:4,代码来源:SmoothArtUIE.cpp
示例15: handle_create_replace_path_canonical
void metadb::handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) {
handle_create(p_out,make_playable_location(p_new_path,p_source->get_subsong_index()));
}
开发者ID:Jorgorbia,项目名称:AltaCast,代码行数:3,代码来源:metadb.cpp
示例16: open
void input_helper::open(service_ptr_t<file> p_filehint,metadb_handle_ptr p_location,unsigned p_flags,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints)
{
open(p_filehint,p_location->get_location(),p_flags,p_abort,p_from_redirect,p_skip_hints);
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:4,代码来源:input_helpers.cpp
示例17: on_playback_new_track
void on_playback_new_track(metadb_handle_ptr p_track) {
CURL *curl;
pfc::string8 authstr=cfg_username;
authstr+=":";
authstr+=cfg_password;
const char* URL="http://api.t.sina.com.cn/statuses/update.xml";
pfc::string8 req_data="source=483394858&lat=0&long=0&status=%e6%88%91%e6%ad%a3%e5%9c%a8%e5%90%ac ";
file_info_impl track_info;
if (p_track->get_info(track_info))
{
const char* track_artist = track_info.meta_get("artist", 0);
const char* track_title = track_info.meta_get("title", 0);
// const char* track_album = track_info.meta_get("album", 0);
//if (track_album == NULL)
// track_album = "";
if (track_artist == NULL)
{
track_artist="N/A ";
}
if (track_title != NULL)
{
/* req_data+="";
req_data+=track_album;
req_data+=" ";*/
req_data+=track_artist;
req_data+="--";
req_data+=track_title;
curl = curl_easy_init();
if(curl) {
//设置url
curl_easy_setopt(curl, CURLOPT_URL,URL);
//设置basic验证信息
const char* authdata=authstr;
curl_easy_setopt(curl,CURLOPT_USERPWD,authdata);
//设置post字段信息
const char* data=req_data;
curl_easy_setopt(curl,CURLOPT_POSTFIELDS,data);
//设置回调函数
curl_easy_setopt(curl,CURLOPT_READFUNCTION,read_callback);
// popup_message::g_complain(authstr);
// popup_message::g_complain(req_data);
// popup_message::g_complain(URL);
//提交
CURLcode res =
curl_easy_perform(curl);
if (res != CURLE_OK)
{
//popup_message::g_complain("fail!");
console::printf( "failed to perform the request '%s' [%s]\n", URL,curl_easy_strerror(res));
}else{
//popup_message::g_complain("success!");
console::printf( "success to perform the request '%s' [%s]\n", URL,curl_easy_strerror(res));
}
/* always cleanup */
curl_easy_cleanup(curl);
}
}
return ;
}
}
开发者ID:Arsunk,项目名称:foo_now_playing,代码行数:77,代码来源:foo_out_send_listening.cpp
示例18: on_playback_new_track
virtual void on_playback_new_track(metadb_handle_ptr track)
{
pfc::string8 out = "";
pfc::string8 fullTitle = "";
pfc::string8 artist = "";
pfc::string8 title = "";
char songTitle[1024] = "";
char songTitle2[1024] = "";
static char currentTitle[1024] = "";
int windowTitle = 1;
char newTitle[2046] = "";
if (track != NULL) {
track->metadb_lock();
const file_info * info;
track->get_info_async_locked(info);
if (info) {
freeComment();
int numInfos = info->meta_get_count();
for (int i=0;i<numInfos;i++) {
const char *pName = info->meta_enum_name(i);
const char *pValue = info->meta_enum_value(i,0);
char *buffer;
int bufferlen = 0;
bufferlen = strlen(pName) + strlen(pValue) + strlen("=") + 1;
buffer = (char *)calloc(1, bufferlen);
sprintf(buffer, "%s=%s", pName, pValue);
pfc::string8 theout = "";
theout.add_string(buffer);
addComment((char *)(const char *)pfc::stringcvt::string_ansi_from_utf8(theout));
free(buffer);
if (pName) {
if (!stricmp(pName, "ARTIST")) {
if (pValue) {
artist.add_string(pValue);
}
}
if (!stricmp(pName, "TITLE")) {
if (pValue) {
title.add_string(" - ");
title.add_string(pValue);
}
}
}
}
if (numInfos == 0) {
static const char * TITLE_FORMAT = "%_filename%";
track->format_title_legacy(0,fullTitle,TITLE_FORMAT,0);
}
else {
fullTitle.add_string(artist);
fullTitle.add_string(title);
/*
track->handle_query_meta_field("ARTIST", 0, out);
fullTitle.add_string(out);
track->handle_query_meta_field("TITLE", 0, out);
fullTitle.add_string(" - ");
fullTitle.add_string(out);
*/
;
}
setMetadataFromMediaPlayer((char *)(const char *)pfc::stringcvt::string_ansi_from_utf8(fullTitle));
}
track->metadb_unlock();
}
}
开发者ID:KolorKode,项目名称:Stg,代码行数:68,代码来源:edcast_foobar.cpp
注:本文中的metadb_handle_ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论