本文整理汇总了C++中meta::TrackPtr::length方法的典型用法代码示例。如果您正苦于以下问题:C++ TrackPtr::length方法的具体用法?C++ TrackPtr::length怎么用?C++ TrackPtr::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta::TrackPtr
的用法示例。
在下文中一共展示了TrackPtr::length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debug
StatSyncing::ScrobblingService::ScrobbleError
ScrobblerAdapter::scrobble( const Meta::TrackPtr &track, double playedFraction,
const QDateTime &time )
{
Q_ASSERT( track );
if( isToBeSkipped( track ) )
{
debug() << "scrobble(): refusing track" << track->prettyUrl()
<< "- contains label:" << m_config->filteredLabel() << "which is marked to be skipped";
return SkippedByUser;
}
if( track->length() * qMin( 1.0, playedFraction ) < 30 * 1000 )
{
debug() << "scrobble(): refusing track" << track->prettyUrl() << "- played time ("
<< track->length() / 1000 << "*" << playedFraction << "s) shorter than 30 s";
return TooShort;
}
int playcount = qRound( playedFraction );
if( playcount <= 0 )
{
debug() << "scrobble(): refusing track" << track->prettyUrl() << "- played "
<< "fraction (" << playedFraction * 100 << "%) less than 50 %";
return TooShort;
}
lastfm::MutableTrack lfmTrack;
copyTrackMetadata( lfmTrack, track );
// since liblastfm >= 1.0.3 it interprets following extra property:
lfmTrack.setExtra( "playCount", QString::number( playcount ) );
lfmTrack.setTimeStamp( time.isValid() ? time : QDateTime::currentDateTime() );
debug() << "scrobble: " << lfmTrack.artist() << "-" << lfmTrack.album() << "-"
<< lfmTrack.title() << "source:" << lfmTrack.source() << "duration:"
<< lfmTrack.duration();
m_scrobbler.cache( lfmTrack );
m_scrobbler.submit(); // since liblastfm 1.0.7, submit() is not called automatically upon cache()
switch( lfmTrack.scrobbleStatus() )
{
case lastfm::Track::Cached:
case lastfm::Track::Submitted:
return NoError;
case lastfm::Track::Null:
case lastfm::Track::Error:
break;
}
return BadMetadata;
}
示例2: setAlignment
void
Amarok::OSD::show( Meta::TrackPtr track ) //slot
{
setAlignment( static_cast<OSDWidget::Alignment>( AmarokConfig::osdAlignment() ) );
setOffset( AmarokConfig::osdYOffset() );
QString text;
if( !track || track->playableUrl().isEmpty() )
{
text = i18n( "No track playing" );
setRating( 0 ); // otherwise stars from last rating change are visible
}
else
{
setRating( track->rating() );
text = track->prettyName();
if( track->artist() && !track->artist()->prettyName().isEmpty() )
text = track->artist()->prettyName() + " - " + text;
if( track->album() && !track->album()->prettyName().isEmpty() )
text += "\n (" + track->album()->prettyName() + ") ";
else
text += '\n';
if( track->length() > 0 )
text += Meta::msToPrettyTime( track->length() );
}
if( text.isEmpty() )
text = track->playableUrl().fileName();
if( text.startsWith( "- " ) ) //When we only have a title tag, _something_ prepends a fucking hyphen. Remove that.
text = text.mid( 2 );
if( text.isEmpty() ) //still
text = i18n("No information available for this track");
QImage image;
if( track && track->album() )
image = The::svgHandler()->imageWithBorder( track->album(), 100, 5 ).toImage();
OSDWidget::show( text, image );
}
示例3: if
void
ScrobblerAdapter::copyTrackMetadata( lastfm::MutableTrack &to, const Meta::TrackPtr &track )
{
to.setTitle( track->name() );
QString artistOrComposer;
Meta::ComposerPtr composer = track->composer();
if( m_config->scrobbleComposer() && composer )
artistOrComposer = composer->name();
Meta::ArtistPtr artist = track->artist();
if( artistOrComposer.isEmpty() && artist )
artistOrComposer = artist->name();
to.setArtist( artistOrComposer );
Meta::AlbumPtr album = track->album();
Meta::ArtistPtr albumArtist;
if( album )
{
to.setAlbum( album->name() );
albumArtist = album->hasAlbumArtist() ? album->albumArtist() : Meta::ArtistPtr();
}
if( albumArtist )
to.setAlbumArtist( albumArtist->name() );
to.setDuration( track->length() / 1000 );
if( track->trackNumber() >= 0 )
to.setTrackNumber( track->trackNumber() );
lastfm::Track::Source source = lastfm::Track::Player;
if( track->type() == "stream/lastfm" )
source = lastfm::Track::LastFmRadio;
else if( track->type().startsWith( "stream" ) )
source = lastfm::Track::NonPersonalisedBroadcast;
else if( track->collection() && track->collection()->collectionId() != "localCollection" )
source = lastfm::Track::MediaDevice;
to.setSource( source );
}
示例4: buildDestination
QString TrackOrganizer::buildDestination(const QString& format, const Meta::TrackPtr& track) const
{
// get hold of the shared pointers
Meta::AlbumPtr album = track->album();
Meta::ArtistPtr artist = track->artist();
Meta::ComposerPtr composer = track->composer();
Meta::ArtistPtr albumArtist = album ? album->albumArtist() : Meta::ArtistPtr();
Meta::GenrePtr genre = track->genre();
Meta::YearPtr year = track->year();
bool isCompilation = album && album->isCompilation();
QMap<QString, QString> args;
QString strArtist = artist ? artist->name() : QString();
QString strAlbumArtist = isCompilation ? i18n( "Various Artists" ) :
( albumArtist ? albumArtist->name() : strArtist );
args["theartist"] = strArtist;
args["thealbumartist"] = strAlbumArtist;
if( m_postfixThe )
{
Amarok::manipulateThe( strArtist, true );
Amarok::manipulateThe( strAlbumArtist, true );
}
if ( track->trackNumber() )
{
QString trackNum = QString("%1").arg( track->trackNumber(), 2, 10, QChar('0') );
args["track"] = trackNum;
}
args["title"] = track->name();
args["artist"] = strArtist;
args["composer"] = composer ? composer->name() : QString();
// if year == 0 then we don't want include it
QString strYear = year ? year->name() : QString();
args["year"] = strYear.localeAwareCompare( "0" ) == 0 ? QString() : strYear;
args["album"] = track->album() ? track->album()->name() : QString();
args["albumartist"] = strAlbumArtist;
args["comment"] = track->comment();
args["genre"] = genre ? genre->name() : QString();
if( m_targetFileExtension.isEmpty() )
args["filetype"] = track->type();
else
args["filetype"] = m_targetFileExtension;
QString strFolder = QFileInfo( track->playableUrl().toLocalFile() ).path();
strFolder = strFolder.mid( commonPrefixLength( m_folderPrefix, strFolder ) );
args["folder"] = strFolder;
args["initial"] = strAlbumArtist.mid( 0, 1 ).toUpper(); //artists starting with The are already handled above
if( track->discNumber() )
args["discnumber"] = QString::number( track->discNumber() );
args["collectionroot"] = m_folderPrefix;
// some additional properties not supported by organize dialog.
args["rating"] = track->statistics()->rating();
args["filesize"] = track->filesize();
args["length"] = track->length() / 1000;
// Fill up default empty values for StringX formater
// TODO make this values changeable by user
args["default_album"] = i18n( "Unknown album" );
args["default_albumartist"] = i18n( "Unknown artist" );
args["default_artist"] = args["albumartist"];
args["default_thealbumartist"] = args["albumartist"];
args["default_theartist"] = args["albumartist"];
args["default_comment"] = i18n( "No comments" );
args["default_composer"] = i18n( "Unknown composer" );
args["default_discnumber"] = i18n( "Unknown disc number" );
args["default_genre"] = i18n( "Unknown genre" );
args["default_title"] = i18n( "Unknown title" );
args["default_year"] = i18n( "Unknown year" );
foreach( const QString &key, args.keys() )
if( key != "collectionroot" && key != "folder" )
args[key] = args[key].replace( '/', '-' );
Amarok::QStringx formatx( format );
QString result = formatx.namedOptArgs( args );
return cleanPath( result );
}
示例5: valueForField
QVariant Meta::valueForField( qint64 field, Meta::TrackPtr track )
{
if( !track )
return QVariant();
switch( field )
{
case 0:
{
// that is the simple search for MetaQueryWidget
QSet<QString> allInfos;
allInfos += track->playableUrl().path()
+= track->name()
+= track->comment();
if( track->artist() )
allInfos += track->artist()->name();
if( track->album() )
allInfos += track->album()->name();
if( track->genre() )
allInfos += track->genre()->name();
return QVariant( allInfos.toList() );
}
case Meta::valUrl: return track->playableUrl().path();
case Meta::valTitle: return track->name();
case Meta::valArtist: return track->artist() ?
QVariant(track->artist()->name()) : QVariant();
case Meta::valAlbum: return track->album() ?
QVariant(track->album()->name()) : QVariant();
case Meta::valGenre: return track->genre() ?
QVariant(track->genre()->name()) : QVariant();
case Meta::valComposer: return track->composer() ?
QVariant(track->composer()->name()) : QVariant();
case Meta::valYear: return track->year() ?
QVariant(track->year()->name().toInt()) : QVariant();
case Meta::valComment: return track->comment();
case Meta::valTrackNr: return track->trackNumber();
case Meta::valDiscNr: return track->discNumber();
case Meta::valBpm: return track->bpm();
case Meta::valLength: return track->length();
case Meta::valBitrate: return track->bitrate();
case Meta::valSamplerate: return track->sampleRate();
case Meta::valFilesize: return track->filesize();
case Meta::valFormat: return int(Amarok::FileTypeSupport::fileType(track->type()));
case Meta::valCreateDate: return track->createDate();
case Meta::valScore: return track->statistics()->score();
case Meta::valRating: return track->statistics()->rating();
case Meta::valFirstPlayed: return track->statistics()->firstPlayed();
case Meta::valLastPlayed: return track->statistics()->lastPlayed();
case Meta::valPlaycount: return track->statistics()->playCount();
case Meta::valUniqueId: return track->uidUrl();
// todo
case Meta::valTrackGain: return "track gain";
case Meta::valTrackGainPeak: return "track gain peak";
case Meta::valAlbumGain: return "album gain";
case Meta::valAlbumGainPeak: return "album gain peak";
case Meta::valAlbumArtist: return (track->album() && track->album()->albumArtist()) ?
QVariant(track->album()->albumArtist()->name()) : QVariant();
case Meta::valLabel:
{
Meta::LabelList labels = track->labels();
QStringList strLabels;
foreach( Meta::LabelPtr label, labels )
strLabels.append( label->name() );
return QVariant( strLabels );
}
case Meta::valModified: return track->modifyDate();
default: return QVariant();
}
}