本文整理汇总了C++中MusicMetadata::Filename方法的典型用法代码示例。如果您正苦于以下问题:C++ MusicMetadata::Filename方法的具体用法?C++ MusicMetadata::Filename怎么用?C++ MusicMetadata::Filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MusicMetadata
的用法示例。
在下文中一共展示了MusicMetadata::Filename方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeSize
void Playlist::computeSize(double &size_in_MB, double &size_in_sec)
{
//double child_MB;
//double child_sec;
// Clear return values
size_in_MB = 0.0;
size_in_sec = 0.0;
SongList::const_iterator it = m_songs.begin();
for (; it != m_songs.end(); ++it)
{
if ((*it)->isCDTrack())
continue;
// Normal track
MusicMetadata *tmpdata = (*it);
if (tmpdata)
{
if (tmpdata->Length() > 0)
size_in_sec += tmpdata->Length();
else
LOG(VB_GENERAL, LOG_ERR, "Computing track lengths. "
"One track <=0");
// Check tmpdata->Filename
QFileInfo finfo(tmpdata->Filename());
size_in_MB += finfo.size() / 1000000;
}
}
}
示例2: fillWidgets
void ImportMusicDialog::fillWidgets()
{
if (!m_tracks->empty())
{
// update current
//: %1 is the current track,
//: %2 is the number of tracks
m_currentText->SetText(tr("%1 of %2", "Current track position")
.arg(m_currentTrack + 1).arg(m_tracks->size()));
MusicMetadata *meta = m_tracks->at(m_currentTrack)->metadata;
m_filenameText->SetText(meta->Filename());
m_compilationCheck->SetCheckState(meta->Compilation());
m_compartistText->SetText(meta->CompilationArtist());
m_artistText->SetText(meta->Artist());
m_albumText->SetText(meta->Album());
m_titleText->SetText(meta->Title());
m_genreText->SetText(meta->Genre());
m_yearText->SetText(QString::number(meta->Year()));
m_trackText->SetText(QString::number(meta->Track()));
if (m_tracks->at(m_currentTrack)->isNewTune)
{
m_coverartButton->SetVisible(false);
m_statusText->SetText(tr("New File"));
}
else
{
m_coverartButton->SetVisible(true);
m_statusText->SetText(tr("Already in Database"));
}
}
else
{
// update current
m_currentText->SetText(tr("Not found"));
m_filenameText->Reset();
m_compilationCheck->SetCheckState(false);
m_compartistText->Reset();
m_artistText->Reset();
m_albumText->Reset();
m_titleText->Reset();
m_genreText->Reset();
m_yearText->Reset();
m_trackText->Reset();
m_statusText->Reset();
m_coverartButton->SetVisible(false);
}
}
示例3: AddFileToDB
/*!
* \brief Insert file details into database.
* If it is an audio file, read the metadata and insert
* that information at the same time.
*
* If it is an image file, just insert the filename and
* type.
*
* \param filename Full path to file.
*
* \returns Nothing.
*/
void MusicFileScanner::AddFileToDB(const QString &filename)
{
QString extension = filename.section( '.', -1 ) ;
QString directory = filename;
directory.remove(0, m_startdir.length());
directory = directory.section( '/', 0, -2);
QString nameFilter = gCoreContext->GetSetting("AlbumArtFilter", "*.png;*.jpg;*.jpeg;*.gif;*.bmp");
// If this file is an image, insert the details into the music_albumart table
if (nameFilter.indexOf(extension.toLower()) > -1)
{
QString name = filename.section( '/', -1);
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("INSERT INTO music_albumart SET filename = :FILE, "
"directory_id = :DIRID, imagetype = :TYPE;");
query.bindValue(":FILE", name);
query.bindValue(":DIRID", m_directoryid[directory]);
query.bindValue(":TYPE", AlbumArtImages::guessImageType(name));
if (!query.exec() || query.numRowsAffected() <= 0)
{
MythDB::DBError("music insert artwork", query);
}
return;
}
LOG(VB_FILE, LOG_INFO,
QString("Reading metadata from %1").arg(filename));
MusicMetadata *data = MetaIO::readMetadata(filename);
if (data)
{
data->setFileSize((quint64)QFileInfo(filename).size());
QString album_cache_string;
// Set values from cache
int did = m_directoryid[directory];
if (did > 0)
data->setDirectoryId(did);
int aid = m_artistid[data->Artist().toLower()];
if (aid > 0)
{
data->setArtistId(aid);
// The album cache depends on the artist id
album_cache_string = data->getArtistId() + "#"
+ data->Album().toLower();
if (m_albumid[album_cache_string] > 0)
data->setAlbumId(m_albumid[album_cache_string]);
}
int gid = m_genreid[data->Genre().toLower()];
if (gid > 0)
data->setGenreId(gid);
// Commit track info to database
data->dumpToDatabase();
// Update the cache
m_artistid[data->Artist().toLower()] =
data->getArtistId();
m_genreid[data->Genre().toLower()] =
data->getGenreId();
album_cache_string = data->getArtistId() + "#"
+ data->Album().toLower();
m_albumid[album_cache_string] = data->getAlbumId();
// read any embedded images from the tag
MetaIO *tagger = MetaIO::createTagger(filename);
if (tagger)
{
if (tagger->supportsEmbeddedImages())
{
AlbumArtList artList = tagger->getAlbumArtList(data->Filename());
data->setEmbeddedAlbumArt(artList);
data->getAlbumArtImages()->dumpToDatabase();
}
delete tagger;
}
delete data;
//.........这里部分代码省略.........
示例4: ExtractImage
static int ExtractImage(const MythUtilCommandLineParser &cmdline)
{
if (cmdline.toString("songid").isEmpty())
{
LOG(VB_GENERAL, LOG_ERR, "Missing --songid option");
return GENERIC_EXIT_INVALID_CMDLINE;
}
if (cmdline.toString("imagetype").isEmpty())
{
LOG(VB_GENERAL, LOG_ERR, "Missing --imagetype option");
return GENERIC_EXIT_INVALID_CMDLINE;
}
int songID = cmdline.toInt("songid");
ImageType type = (ImageType)cmdline.toInt("imagetype");
MusicMetadata *mdata = MusicMetadata::createFromID(songID);
if (!mdata)
{
LOG(VB_GENERAL, LOG_ERR, QString("Cannot find metadata for trackid: %1").arg(songID));
return GENERIC_EXIT_NOT_OK;
}
AlbumArtImage *image = mdata->getAlbumArtImages()->getImage(type);
if (!image)
{
LOG(VB_GENERAL, LOG_ERR, QString("Cannot find image of type: %1").arg(type));
return GENERIC_EXIT_NOT_OK;
}
MetaIO *tagger = mdata->getTagger();
if (!tagger)
{
LOG(VB_GENERAL, LOG_ERR, QString("Cannot find a tagger for this file: %1").arg(mdata->Filename(false)));
return GENERIC_EXIT_NOT_OK;
}
if (!image->embedded || !tagger->supportsEmbeddedImages())
{
LOG(VB_GENERAL, LOG_ERR, QString("Either the image isn't embedded or the tagger doesn't support embedded images"));
return GENERIC_EXIT_NOT_OK;
}
// find the tracks actual filename
StorageGroup musicGroup("Music", gCoreContext->GetHostName(), false);
QString trackFilename = musicGroup.FindFile(mdata->Filename(false));
// where are we going to save the image
QString path;
StorageGroup artGroup("MusicArt", gCoreContext->GetHostName(), false);
QStringList dirList = artGroup.GetDirList();
if (dirList.size())
path = artGroup.FindNextDirMostFree();
if (!QDir(path).exists())
{
LOG(VB_GENERAL, LOG_ERR, "Cannot find a directory in the 'MusicArt' storage group to save to");
return GENERIC_EXIT_NOT_OK;
}
path += "/AlbumArt/";
QDir dir(path);
QString filename = QString("%1-%2.jpg").arg(mdata->ID()).arg(AlbumArtImages::getTypeFilename(image->imageType));
if (QFile::exists(path + filename))
QFile::remove(path + filename);
if (!dir.exists())
dir.mkpath(path);
QImage *saveImage = tagger->getAlbumArt(trackFilename, image->imageType);
if (saveImage)
{
saveImage->save(path + filename, "JPEG");
delete saveImage;
}
delete tagger;
// tell any clients that the albumart for this track has changed
gCoreContext->SendMessage(QString("MUSIC_ALBUMART_CHANGED %1 %2").arg(songID).arg(type));
return GENERIC_EXIT_OK;
}
示例5: testit
int Playlist::CreateCDMP3(void)
{
// Check & get global settings
if (!gCoreContext->GetNumSetting("CDWriterEnabled"))
{
LOG(VB_GENERAL, LOG_ERR, "CD Writer is not enabled.");
return 1;
}
QString scsidev = MediaMonitor::defaultCDWriter();
if (scsidev.isEmpty())
{
LOG(VB_GENERAL, LOG_ERR, "No CD Writer device defined.");
return 1;
}
int disksize = gCoreContext->GetNumSetting("CDDiskSize", 2);
QString writespeed = gCoreContext->GetSetting("CDWriteSpeed", "2");
bool MP3_dir_flag = gCoreContext->GetNumSetting("CDCreateDir", 1);
double size_in_MB = 0.0;
QStringList reclist;
SongList::const_iterator it = m_songs.begin();
for (; it != m_songs.end(); ++it)
{
if ((*it)->isCDTrack())
continue;
// Normal track
MusicMetadata *tmpdata = (*it);
if (tmpdata)
{
// check filename..
QFileInfo testit(tmpdata->Filename());
if (!testit.exists())
continue;
size_in_MB += testit.size() / 1000000.0;
QString outline;
if (MP3_dir_flag)
{
if (tmpdata->Artist().length() > 0)
outline += tmpdata->Artist() + "/";
if (tmpdata->Album().length() > 0)
outline += tmpdata->Album() + "/";
}
outline += "=";
outline += tmpdata->Filename();
reclist += outline;
}
}
int max_size;
if (disksize == 0)
max_size = 650;
else
max_size = 700;
if (size_in_MB >= max_size)
{
LOG(VB_GENERAL, LOG_ERR, "MP3 CD creation aborted -- cd size too big.");
return 1;
}
// probably should tie stdout of mkisofs to stdin of cdrecord sometime
QString tmptemplate("/tmp/mythmusicXXXXXX");
QString tmprecordlist = createTempFile(tmptemplate);
if (tmprecordlist == tmptemplate)
{
LOG(VB_GENERAL, LOG_ERR, "Unable to open temporary file");
return 1;
}
QString tmprecordisofs = createTempFile(tmptemplate);
if (tmprecordisofs == tmptemplate)
{
LOG(VB_GENERAL, LOG_ERR, "Unable to open temporary file");
return 1;
}
QFile reclistfile(tmprecordlist);
if (!reclistfile.open(QIODevice::WriteOnly))
{
LOG(VB_GENERAL, LOG_ERR, "Unable to open temporary file");
return 1;
}
QTextStream recstream(&reclistfile);
QStringList::Iterator iter;
for (iter = reclist.begin(); iter != reclist.end(); ++iter)
{
recstream << *iter << "\n";
}
//.........这里部分代码省略.........