void TrackInfoObject::parse() { // Log parsing of header information in developer mode. This is useful for // tracking down corrupt files. const QString& canonicalLocation = m_fileInfo.canonicalFilePath(); if (CmdlineArgs::Instance().getDeveloper()) { qDebug() << "TrackInfoObject::parse()" << canonicalLocation; } // Parse the information stored in the sound file. SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken); Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource(); if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) { // Dump the metadata extracted from the file into the track. // TODO(XXX): This involves locking the mutex for every setXXX // method. We should figure out an optimization where there are private // setters that don't lock the mutex. // If Artist, Title and Type fields are not blank, modify them. // Otherwise, keep their current values. // TODO(rryan): Should we re-visit this decision? if (!(pProxiedSoundSource->getArtist().isEmpty())) { setArtist(pProxiedSoundSource->getArtist()); } if (!(pProxiedSoundSource->getTitle().isEmpty())) { setTitle(pProxiedSoundSource->getTitle()); } if (!(pProxiedSoundSource->getType().isEmpty())) { setType(pProxiedSoundSource->getType()); } setAlbum(pProxiedSoundSource->getAlbum()); setAlbumArtist(pProxiedSoundSource->getAlbumArtist()); setYear(pProxiedSoundSource->getYear()); setGenre(pProxiedSoundSource->getGenre()); setComposer(pProxiedSoundSource->getComposer()); setGrouping(pProxiedSoundSource->getGrouping()); setComment(pProxiedSoundSource->getComment()); setTrackNumber(pProxiedSoundSource->getTrackNumber()); setReplayGain(pProxiedSoundSource->getReplayGain()); setBpm(pProxiedSoundSource->getBPM()); setDuration(pProxiedSoundSource->getDuration()); setBitrate(pProxiedSoundSource->getBitrate()); setSampleRate(pProxiedSoundSource->getSampleRate()); setChannels(pProxiedSoundSource->getChannels()); setKeyText(pProxiedSoundSource->getKey(), mixxx::track::io::key::FILE_METADATA); setHeaderParsed(true); } else { qDebug() << "TrackInfoObject::parse() error at file" << canonicalLocation; setHeaderParsed(false); // Add basic information derived from the filename: parseFilename(); } }
void PluginTrack::loadTrack(const QString &service, const QVariantMap &track) { setService(service); setArtist(track.value("artist").toString()); setArtistId(track.value("artistId").toString()); setDate(track.value("date").toString()); setDescription(track.value("description").toString()); setDownloadable(track.value("downloadable", true).toBool()); setFormat(track.value("format").toString()); setGenre(track.value("genre").toString()); setId(track.value("id").toString()); setLargeThumbnailUrl(track.value("largeThumbnailUrl").toString()); setPlayCount(track.value("playCount").toLongLong()); setStreamUrl(track.value("streamUrl").toString()); setThumbnailUrl(track.value("thumbnailUrl").toString()); setTitle(track.value("title").toString()); setUrl(track.value("url").toString()); if (track.value("duration").type() == QVariant::String) { setDurationString(track.value("duration").toString()); } else { setDuration(track.value("duration").toLongLong()); } if (track.value("size").type() == QVariant::String) { setSizeString(track.value("size").toString()); } else { setSize(track.value("size").toLongLong()); } }
void Media::setArtistAndUpdateRelations(const QSharedPointer< Media >& media, const QSharedPointer< Artist >& artist) { QSharedPointer<Artist> originalArtist = media->artist(); if (setArtist(artist)) { if (originalArtist) { originalArtist->removeMedia(media); } artist->addMedia(media); } }
void MediaPlayer :: metaDataCallback() { if(player->metaData(QMediaMetaData::Title).toString() != "") { setTitle(player->metaData(QMediaMetaData::Title).toString()); } else { setTitle(QFileInfo(player->currentMedia().canonicalUrl().toString()).fileName()); } if(player->metaData(QMediaMetaData::AlbumArtist).toString() != "") { setArtist(player->metaData(QMediaMetaData::AlbumArtist).toString()); } else { setArtist("Unknown Artist"); } }
void EditMetadataDialog::searchArtist() { QString msg = tr("Select an Artist"); QStringList searchList = Metadata::fillFieldList("artist"); QString s = m_metadata->Artist(); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythUISearchDialog *searchDlg = new MythUISearchDialog(popupStack, msg, searchList, false, s); if (!searchDlg->Create()) { delete searchDlg; return; } connect(searchDlg, SIGNAL(haveResult(QString)), SLOT(setArtist(QString))); popupStack->AddScreen(searchDlg); }
void GraffitiTab::save () { const auto& modified = FilesModel_->GetModified (); if (modified.isEmpty ()) return; if (QMessageBox::question (this, "LMP Graffiti", tr ("Do you really want to accept changes to %n file(s)?", 0, modified.size ()), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; ITagResolver *resolver = LMPProxy_->GetTagResolver (); auto toTLStr = [] (const QString& str) { return TagLib::String (str.toUtf8 ().constData (), TagLib::String::UTF8); }; for (const auto& pair : modified) { const auto& newInfo = pair.first; QMutexLocker locker (&resolver->GetMutex ()); auto file = resolver->GetFileRef (newInfo.LocalPath_); auto tag = file.tag (); tag->setArtist (toTLStr (newInfo.Artist_)); tag->setAlbum (toTLStr (newInfo.Album_)); tag->setTitle (toTLStr (newInfo.Title_)); tag->setYear (newInfo.Year_); tag->setGenre (toTLStr (newInfo.Genres_.join (" / "))); tag->setTrack (newInfo.TrackNumber_); if (!file.save ()) qWarning () << Q_FUNC_INFO << "unable to save file" << newInfo.LocalPath_; } handleRereadFiles (); }
void OsuUISongBrowserInfoLabel::setFromMissingBeatmap(long beatmapId) { m_iBeatmapId = beatmapId; setArtist(m_iBeatmapId > 0 ? "CLICK HERE TO DOWNLOAD" : "MISSING BEATMAP!"); setTitle(""); setDiff("no map"); setMapper("MISSING BEATMAP!"); setLengthMS(0); setBPM(0, 0); setNumObjects(0); setCS(0); setAR(0); setOD(0); setHP(0); setStars(0); setLocalOffset(0); setOnlineOffset(0); }
void OsuUISongBrowserInfoLabel::setFromBeatmap(OsuBeatmap *beatmap, OsuBeatmapDifficulty *diff) { m_iBeatmapId = diff->beatmapId; setArtist(diff->artist); setTitle(diff->title); setDiff(diff->name); setMapper(diff->creator); setLengthMS(beatmap->getLength()); setBPM(diff->minBPM, diff->maxBPM); setNumObjects(diff->numObjects); setCS(diff->CS); setAR(diff->AR); setOD(diff->OD); setHP(diff->HP); setStars(diff->starsNoMod); setLocalOffset(diff->localoffset); setOnlineOffset(diff->onlineOffset); }
void MetadataEditor::loadResult( const Tomahawk::result_ptr& result ) { if ( result.isNull() ) return; m_result = result; setEditable( result->collection() && result->collection()->source()->isLocal() ); setTitle( result->track()->track() ); setArtist( result->track()->artist() ); setAlbum( result->track()->album() ); setAlbumPos( result->track()->albumpos() ); setDuration( result->track()->duration() ); setYear( result->track()->year() ); setBitrate( result->bitrate() ); if ( result->collection() && result->collection()->source()->isLocal() ) { QString furl = m_result->url(); if ( furl.startsWith( "file://" ) ) furl = furl.right( furl.length() - 7 ); QFileInfo fi( furl ); setFileName( fi.absoluteFilePath() ); setFileSize( TomahawkUtils::filesizeToString( fi.size() ) ); } setWindowTitle( result->track()->track() ); if ( m_interface ) { m_index = m_interface->indexOfResult( result ); if ( m_index >= 0 ) enablePushButtons(); } }
void MediaPlayer :: checkPlaylist(int currentIndex) { // this fires on startup with index -1 for some reason if(currentIndex != -1) { setArtist(plModel->data(plModel->index(currentIndex), plModel->Artist).toString()); setTitle(plModel->data(plModel->index(currentIndex), plModel->Title).toString()); qDebug() << "currIndex: " << currentIndex; emit currentIndexChanged(); if(autoQueue) { //check if current item is the last in list if(currentIndex == (playlist->mediaCount() -1)) { //insert random item next tracker->randomItem(); } } } }
void MetadataEditor::loadQuery( const Tomahawk::query_ptr& query ) { if ( query.isNull() ) return; if ( query->numResults() ) { loadResult( query->results().first() ); return; } m_result = Tomahawk::result_ptr(); m_query = query; setEditable( false ); setTitle( query->track()->track() ); setArtist( query->track()->artist() ); setAlbum( query->track()->album() ); setAlbumPos( query->track()->albumpos() ); setDuration( query->track()->duration() ); setYear( 0 ); setBitrate( 0 ); setFileName( QString() ); setFileSize( 0 ); setWindowTitle( query->track()->track() ); if ( m_interface ) { m_index = m_interface->indexOfQuery( query ); if ( m_index >= 0 ) enablePushButtons(); } }
void ImportMusicDialog::showMenu() { if (m_popupMenu) return; if (m_tracks->size() == 0) return; MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythDialogBox *menu = new MythDialogBox("", popupStack, "importmusicmenu"); if (menu->Create()) popupStack->AddScreen(menu); else { delete menu; return; } menu->SetReturnEvent(this, "menu"); menu->AddButton(tr("Save Defaults"), SLOT(saveDefaults())); if (m_haveDefaults) { menu->AddButton(tr("Change Compilation Flag"), SLOT(setCompilation())); menu->AddButton(tr("Change Compilation Artist"), SLOT(setCompilationArtist())); menu->AddButton(tr("Change Artist"), SLOT(setArtist())); menu->AddButton(tr("Change Album"), SLOT(setAlbum())); menu->AddButton(tr("Change Genre"), SLOT(setGenre())); menu->AddButton(tr("Change Year"), SLOT(setYear())); menu->AddButton(tr("Change Rating"), SLOT(setRating())); } menu->AddButton(tr("Cancel")); }
void PL_OggFile::setValue(dataColumn x,QVariant& value,bool replace) { if(!linked) link(); oggtagger->setValue(x,value,replace); bool a; switch(x) { case TITLE: setTitle(value.toString()); break; case ARTIST: setArtist(value.toString()); break; case ALBUM: setAlbumtitle(value.toString()); break; case GENRE: setGenre(value.toInt(&a)); break; case COMMENT: setComment(value.toString()); break; case YEAR: setYear(value.toInt(&a)); break; case TRACK: setTrack(value.toInt(&a)); break; case TIME: case BITRATE: case PICTURE: break; } }
bool SoundSource::processTaglibFile(TagLib::File& f) { if (s_bDebugMetadata) qDebug() << "Parsing" << getFilename(); if (f.isValid()) { TagLib::Tag *tag = f.tag(); if (tag) { QString title = TStringToQString(tag->title()); setTitle(title); QString artist = TStringToQString(tag->artist()); setArtist(artist); QString album = TStringToQString(tag->album()); setAlbum(album); QString comment = TStringToQString(tag->comment()); setComment(comment); QString genre = TStringToQString(tag->genre()); setGenre(genre); int iYear = tag->year(); QString year = ""; if (iYear > 0) { year = QString("%1").arg(iYear); setYear(year); } int iTrack = tag->track(); QString trackNumber = ""; if (iTrack > 0) { trackNumber = QString("%1").arg(iTrack); setTrackNumber(trackNumber); } if (s_bDebugMetadata) qDebug() << "TagLib" << "title" << title << "artist" << artist << "album" << album << "comment" << comment << "genre" << genre << "year" << year << "trackNumber" << trackNumber; } TagLib::AudioProperties *properties = f.audioProperties(); if (properties) { int lengthSeconds = properties->length(); int bitrate = properties->bitrate(); int sampleRate = properties->sampleRate(); int channels = properties->channels(); if (s_bDebugMetadata) qDebug() << "TagLib" << "length" << lengthSeconds << "bitrate" << bitrate << "sampleRate" << sampleRate << "channels" << channels; setDuration(lengthSeconds); setBitrate(bitrate); setSampleRate(sampleRate); setChannels(channels); } // If we didn't get any audio properties, this was a failure. return (properties!=NULL); } return false; }
bool ImportMusicDialog::keyPressEvent(QKeyEvent *event) { if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event)) return true; bool handled = false; QStringList actions; handled = GetMythMainWindow()->TranslateKeyPress("Global", event, actions); for (int i = 0; i < actions.size() && !handled; i++) { QString action = actions[i]; handled = true; if (action == "LEFT") { m_prevButton->Push(); } else if (action == "RIGHT") { m_nextButton->Push(); } else if (action == "EDIT") { showEditMetadataDialog(); } else if (action == "MENU") { showMenu(); } else if (action == "1") { setCompilation(); } else if (action == "2") { setCompilationArtist(); } else if (action == "3") { setArtist(); } else if (action == "4") { setAlbum(); } else if (action == "5") { setGenre(); } else if (action == "6") { setYear(); } else if (action == "7") { setRating(); } else if (action == "8") { setTitleWordCaps(); } else if (action == "9") { setTitleInitialCap(); } else if (action == "0") { setTrack(); } else handled = false; } if (!handled && MythScreenType::keyPressEvent(event)) handled = true; return handled; }
Album::Album(Artist *artist, const char *name) : name(0) { setName(name); setArtist(artist); }
void PhononItem::metaStateChanged(Phonon::State newState, Phonon::State oldState) { Q_UNUSED(oldState); // static QObjectWriter writer(this, false); if (newState == Phonon::ErrorState) { qDebug() << "PhononItem: Error Opening File: " << fileName(); emit fetched(false); return; } if (m_metaMedia->currentSource().type() == Phonon::MediaSource::Invalid) { emit fetched(false); qDebug() << "Invalid metadata: " << fileName(); return; } QMap<QString, QString> metaData = m_metaMedia->metaData(); setArtist(metaData.value("ARTIST")); setTrackTitle(metaData.value("TITLE")); setAlbumTitle(metaData.value("ALBUM")); setGenre(metaData.value("GENRE")); QString tn = metaData.value("TRACK-NUMBER"); if (tn == QString()) tn = metaData.value("TRACKNUMBER"); setTrackNumber(tn); extendedComment = QString(); QString comment = metaData.value("COMMENT"); setComment(comment); // http://www.freedesktop.org/wiki/Specifications/free-media-player-specs QString fmpsRating = metaData.value("FMPS_Rating"); // ??? Why does this not work? if (fmpsRating.toDouble() > 0 ) { int stars = fmpsRating.toDouble() * 10; Preference fmpsPref(stars); qDebug() << "FMPS Rating: " << stars; setPreference(fmpsPref); } // Preference can be obtained from various ways. else setPreference(comment); // Check for MusicMatch preference if ((preference().intValue() == 0) && metaData.contains("EXTENDED-COMMENT")) { extendedComment = metaData.value("EXTENDED-COMMENT"); int eqidx = extendedComment.indexOf("="); if (eqidx > 0) extendedComment=extendedComment.mid(eqidx+1); Preference p(extendedComment); if (p.intValue() > 0) { setPreference(p); setComment(p.toString()); } } //start id="notify" m_loaded = true; if (m_timeSet) { emit fetched(); } //end }
{ m_batchMode = true; foreach( TrackEditorPtr ec, m_editors ) ec->beginUpdate(); } void endUpdate() { foreach( TrackEditorPtr ec, m_editors ) ec->endUpdate(); m_batchMode = false; QTimer::singleShot( 0, m_collection, SLOT(slotUpdated()) ); } void setComment( const QString &newComment ) { FORWARD( setComment( newComment ) ) } void setTrackNumber( int newTrackNumber ) { FORWARD( setTrackNumber( newTrackNumber ) ) } void setDiscNumber( int newDiscNumber ) { FORWARD( setDiscNumber( newDiscNumber ) ) } void setBpm( const qreal newBpm ) { FORWARD( setBpm( newBpm ) ) } void setTitle( const QString &newTitle ) { FORWARD( setTitle( newTitle ) ) } void setArtist( const QString &newArtist ) { FORWARD( setArtist( newArtist ) ) } void setAlbum( const QString &newAlbum ) { FORWARD( setAlbum( newAlbum ) ) } void setAlbumArtist( const QString &newAlbumArtist ) { FORWARD( setAlbumArtist ( newAlbumArtist ) ) } void setGenre( const QString &newGenre ) { FORWARD( setGenre( newGenre ) ) } void setComposer( const QString &newComposer ) { FORWARD( setComposer( newComposer ) ) } void setYear( int newYear ) { FORWARD( setYear( newYear ) ) } private: bool m_batchMode; Collections::AggregateCollection *m_collection; QList<TrackEditorPtr> m_editors; }; #undef FORWARD AggregateTrack::AggregateTrack( Collections::AggregateCollection *coll, const TrackPtr &track ) : Track()