本文整理汇总了C++中MusicMetadata::Album方法的典型用法代码示例。如果您正苦于以下问题:C++ MusicMetadata::Album方法的具体用法?C++ MusicMetadata::Album怎么用?C++ MusicMetadata::Album使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MusicMetadata
的用法示例。
在下文中一共展示了MusicMetadata::Album方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: ScanFinished
void Ripper::ScanFinished()
{
delete m_scanThread;
m_scanThread = nullptr;
m_tracks->clear();
if (m_decoder)
{
MusicMetadata *metadata;
bool isCompilation = false;
m_artistName.clear();
m_albumName.clear();
m_genreName.clear();
m_year.clear();
for (int trackno = 0; trackno < m_decoder->getNumTracks(); trackno++)
{
RipTrack *ripTrack = new RipTrack;
metadata = m_decoder->getMetadata(trackno + 1);
if (metadata)
{
ripTrack->metadata = metadata;
ripTrack->length = metadata->Length();
if (metadata->Compilation())
{
isCompilation = true;
m_artistName = metadata->CompilationArtist();
}
else if (m_artistName.isEmpty())
{
m_artistName = metadata->Artist();
}
if (m_albumName.isEmpty())
m_albumName = metadata->Album();
if (m_genreName.isEmpty() && !metadata->Genre().isEmpty())
m_genreName = metadata->Genre();
if (m_year.isEmpty() && metadata->Year() > 0)
m_year = QString::number(metadata->Year());
QString title = metadata->Title();
ripTrack->isNew = isNewTune(m_artistName, m_albumName, title);
ripTrack->active = ripTrack->isNew;
m_tracks->push_back(ripTrack);
}
else
delete ripTrack;
}
m_artistEdit->SetText(m_artistName);
m_albumEdit->SetText(m_albumName);
m_genreEdit->SetText(m_genreName);
m_yearEdit->SetText(m_year);
m_compilationCheck->SetCheckState(isCompilation);
if (!isCompilation)
m_switchTitleArtist->SetVisible(false);
else
m_switchTitleArtist->SetVisible(true);
}
BuildFocusList();
updateTrackList();
CloseBusyPopup();
}
示例3: deleteExistingTrack
bool Ripper::deleteExistingTrack(RipTrack *track)
{
if (!track)
return false;
MusicMetadata *metadata = track->metadata;
if (!metadata)
return false;
QString artist = metadata->Artist();
QString album = metadata->Album();
QString title = metadata->Title();
MSqlQuery query(MSqlQuery::InitCon());
QString queryString("SELECT song_id, "
"CONCAT_WS('/', music_directories.path, music_songs.filename) AS filename "
"FROM music_songs "
"LEFT JOIN music_artists"
" ON music_songs.artist_id=music_artists.artist_id "
"LEFT JOIN music_albums"
" ON music_songs.album_id=music_albums.album_id "
"LEFT JOIN music_directories "
" ON music_songs.directory_id=music_directories.directory_id "
"WHERE artist_name REGEXP \'");
QString token = artist;
token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"),
QString("."));
queryString += token + "\' AND " + "album_name REGEXP \'";
token = album;
token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"),
QString("."));
queryString += token + "\' AND " + "name REGEXP \'";
token = title;
token.replace(QRegExp("(/|\\\\|:|\'|\\,|\\!|\\(|\\)|\"|\\?|\\|)"),
QString("."));
queryString += token + "\' ORDER BY artist_name, album_name,"
" name, song_id, filename LIMIT 1";
query.prepare(queryString);
if (!query.exec() || !query.isActive())
{
MythDB::DBError("Search music database", query);
return false;
}
if (query.next())
{
int trackID = query.value(0).toInt();
QString filename = query.value(1).toString();
QUrl url(m_musicStorageDir);
filename = gCoreContext->GenMythURL(url.host(), 0, filename, "Music");
// delete file
// FIXME: RemoteFile::DeleteFile will only work with files on the master BE
if (!RemoteFile::DeleteFile(filename))
{
LOG(VB_GENERAL, LOG_NOTICE, QString("Ripper::deleteExistingTrack() "
"Could not delete %1")
.arg(filename));
return false;
}
// remove database entry
MSqlQuery deleteQuery(MSqlQuery::InitCon());
deleteQuery.prepare("DELETE FROM music_songs"
" WHERE song_id = :SONG_ID");
deleteQuery.bindValue(":SONG_ID", trackID);
if (!deleteQuery.exec())
{
MythDB::DBError("Delete Track", deleteQuery);
return false;
}
return true;
}
return false;
}
示例4: run
void CDRipperThread::run(void)
{
RunProlog();
if (m_tracks->size() <= 0)
{
RunEpilog();
return;
}
m_totalSectors = 0;
m_totalSectorsDone = 0;
for (int trackno = 0; trackno < m_tracks->size(); trackno++)
{
m_totalSectors += getSectorCount(m_CDdevice, trackno + 1);
}
if (!m_totalSectors)
{
RunEpilog();
return;
}
MusicMetadata *track = m_tracks->at(0)->metadata;
QString tots;
if (track->Compilation())
{
tots = track->CompilationArtist() + " ~ " + track->Album();
}
else
{
tots = track->Artist() + " ~ " + track->Album();
}
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kOverallTextEvent, tots));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kOverallProgressEvent, 0));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackProgressEvent, 0));
QString textstatus;
QString encodertype = gCoreContext->GetSetting("EncoderType");
bool mp3usevbr = gCoreContext->GetNumSetting("Mp3UseVBR", 0);
QApplication::postEvent(m_parent,
new RipStatusEvent(RipStatusEvent::kOverallStartEvent, m_totalSectors));
if (LCD *lcd = LCD::Get())
{
QString lcd_tots = tr("Importing %1").arg(tots);
QList<LCDTextItem> textItems;
textItems.append(LCDTextItem(1, ALIGN_CENTERED,
lcd_tots, "Generic", false));
lcd->switchToGeneric(textItems);
}
MusicMetadata *titleTrack = nullptr;
QString saveDir = GetConfDir() + "/tmp/RipTemp/";
QString outfile;
std::unique_ptr<Encoder> encoder;
for (int trackno = 0; trackno < m_tracks->size(); trackno++)
{
if (isCancelled())
break;
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kStatusTextEvent,
QString("Track %1 of %2")
.arg(trackno + 1).arg(m_tracks->size())));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackProgressEvent, 0));
track = m_tracks->at(trackno)->metadata;
if (track)
{
textstatus = track->Title();
QApplication::postEvent(
m_parent,
new RipStatusEvent(
RipStatusEvent::kTrackTextEvent, textstatus));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackProgressEvent, 0));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackPercentEvent, 0));
// do we need to start a new file?
if (m_tracks->at(trackno)->active)
//.........这里部分代码省略.........
示例5: 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;
//.........这里部分代码省略.........
示例6: handleCDMedia
static void handleCDMedia(MythMediaDevice *cd)
{
if (!cd)
return;
LOG(VB_MEDIA, LOG_NOTICE, "Got a media changed event");
QString newDevice;
// save the device if valid
if (cd->isUsable())
{
#ifdef Q_OS_MAC
newDevice = cd->getMountPath();
#else
newDevice = cd->getDevicePath();
#endif
gCDdevice = newDevice;
LOG(VB_MEDIA, LOG_INFO, "MythMusic: Storing CD device " + gCDdevice);
}
else
{
LOG(VB_MEDIA, LOG_INFO, "Device is not usable clearing cd data");
if (gPlayer->isPlaying() && gPlayer->getCurrentMetadata()
&& gPlayer->getCurrentMetadata()->isCDTrack())
{
// we was playing a cd track which is no longer available so stop playback
// TODO should check the playing track is from the ejected drive if more than one is available
gPlayer->stop(true);
}
// device is not usable so remove any existing CD tracks
if (gMusicData->all_music)
{
gMusicData->all_music->clearCDData();
gMusicData->all_playlists->getActive()->removeAllCDTracks();
}
gPlayer->activePlaylistChanged(-1, false);
gPlayer->sendCDChangedEvent();
return;
}
if (!gMusicData->initialized)
gMusicData->loadMusic();
// remove any existing CD tracks
if (gMusicData->all_music)
{
gMusicData->all_music->clearCDData();
gMusicData->all_playlists->getActive()->removeAllCDTracks();
}
// find any new cd tracks
CdDecoder *decoder = new CdDecoder("cda", NULL, NULL);
decoder->setDevice(newDevice);
int tracks = decoder->getNumTracks();
bool setTitle = false;
for (int trackNo = 1; trackNo <= tracks; trackNo++)
{
MusicMetadata *track = decoder->getMetadata(trackNo);
if (track)
{
gMusicData->all_music->addCDTrack(*track);
if (!setTitle)
{
QString parenttitle = " ";
if (track->FormatArtist().length() > 0)
{
parenttitle += track->FormatArtist();
parenttitle += " ~ ";
}
if (track->Album().length() > 0)
parenttitle += track->Album();
else
{
parenttitle = " " + qApp->translate("(MythMusicMain)",
"Unknown");
LOG(VB_GENERAL, LOG_INFO, "Couldn't find your "
" CD. It may not be in the freedb database.\n"
" More likely, however, is that you need to delete\n"
" ~/.cddb and ~/.cdserverrc and restart MythMusic.");
}
gMusicData->all_music->setCDTitle(parenttitle);
setTitle = true;
}
delete track;
}
}
//.........这里部分代码省略.........
示例7: shuffleTracks
//.........这里部分代码省略.........
// 'totalWeights' so at a point 'pos' will never be
// greater or equal to 'hit' and we will always hit the
// end of the map
if (weightIt == weightEnd)
break;
order[weightIt->first] = orderCpt;
totalWeights -= weightIt->second;
weights.erase(weightIt);
++orderCpt;
}
// create a map of tracks sorted by the computed order
QMultiMap<int, MusicMetadata*> songMap;
it = m_songs.begin();
for (; it != m_songs.end(); ++it)
songMap.insert(order[(*it)->ID()], *it);
// copy the shuffled tracks to the shuffled song list
QMultiMap<int, MusicMetadata*>::const_iterator i = songMap.constBegin();
while (i != songMap.constEnd())
{
m_shuffledSongs.append(i.value());
++i;
}
break;
}
case MusicPlayer::SHUFFLE_ALBUM:
{
// "intellegent/album" order
typedef map<QString, uint32_t> AlbumMap;
AlbumMap album_map;
AlbumMap::iterator Ialbum;
QString album;
// pre-fill the album-map with the album name.
// This allows us to do album mode in album order
SongList::const_iterator it = m_songs.begin();
for (; it != m_songs.end(); ++it)
{
MusicMetadata *mdata = (*it);
album = mdata->Album() + " ~ " + QString("%1").arg(mdata->getAlbumId());
if ((Ialbum = album_map.find(album)) == album_map.end())
album_map.insert(AlbumMap::value_type(album, 0));
}
// populate the sort id into the album map
uint32_t album_count = 1;
for (Ialbum = album_map.begin(); Ialbum != album_map.end(); ++Ialbum)
{
Ialbum->second = album_count;
album_count++;
}
// create a map of tracks sorted by the computed order
QMultiMap<int, MusicMetadata*> songMap;
it = m_songs.begin();
for (; it != m_songs.end(); ++it)
{
uint32_t album_order;
MusicMetadata *mdata = (*it);
if (mdata)
{
示例8: 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";
}
//.........这里部分代码省略.........