本文整理汇总了C++中tomahawk::result_ptr::bitrate方法的典型用法代码示例。如果您正苦于以下问题:C++ result_ptr::bitrate方法的具体用法?C++ result_ptr::bitrate怎么用?C++ result_ptr::bitrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tomahawk::result_ptr
的用法示例。
在下文中一共展示了result_ptr::bitrate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fi
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();
}
}
示例2: localeAwareCompare
bool
PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const Tomahawk::query_ptr& q2 ) const
{
// Attention: This function may be called very often!
// So be aware of its performance.
const Tomahawk::track_ptr& t1 = q1->track();
const Tomahawk::track_ptr& t2 = q2->track();
const QString& artist1 = t1->artistSortname();
const QString& artist2 = t2->artistSortname();
const QString& album1 = t1->albumSortname();
const QString& album2 = t2->albumSortname();
const unsigned int albumpos1 = t1->albumpos();
const unsigned int albumpos2 = t2->albumpos();
const unsigned int discnumber1 = t1->discnumber();
const unsigned int discnumber2 = t2->discnumber();
const qint64 id1 = (qint64)&q1;
const qint64 id2 = (qint64)&q2;
if ( column == PlayableModel::Artist ) // sort by artist
{
if ( artist1 == artist2 )
{
if ( album1 == album2 )
{
if ( discnumber1 == discnumber2 )
{
if ( albumpos1 == albumpos2 )
return id1 < id2;
return albumpos1 < albumpos2;
}
return discnumber1 < discnumber2;
}
return QString::localeAwareCompare( album1, album2 ) < 0;
}
return QString::localeAwareCompare( artist1, artist2 ) < 0;
}
// Sort by Composer
const QString& composer1 = t1->composerSortname();
const QString& composer2 = t2->composerSortname();
if ( column == PlayableModel::Composer )
{
if ( composer1 == composer2 )
{
if ( album1 == album2 )
{
if ( discnumber1 == discnumber2 )
{
if ( albumpos1 == albumpos2 )
return id1 < id2;
return albumpos1 < albumpos2;
}
return discnumber1 < discnumber2;
}
return QString::localeAwareCompare( album1, album2 ) < 0;
}
return QString::localeAwareCompare( composer1, composer2 ) < 0;
}
// Sort by Album
if ( column == PlayableModel::Album ) // sort by album
{
if ( album1 == album2 )
{
if ( discnumber1 == discnumber2 )
{
if ( albumpos1 == albumpos2 )
return id1 < id2;
return albumpos1 < albumpos2;
}
return discnumber1 < discnumber2;
}
return QString::localeAwareCompare( album1, album2 ) < 0;
}
// Lazy load these variables, they are not used before.
unsigned int bitrate1 = 0, bitrate2 = 0;
unsigned int mtime1 = 0, mtime2 = 0;
unsigned int size1 = 0, size2 = 0;
unsigned int year1 = 0, year2 = 0;
float score1 = 0, score2 = 0;
QString origin1;
QString origin2;
if ( !q1->results().isEmpty() )
{
Tomahawk::result_ptr r = q1->results().first();
bitrate1 = r->bitrate();
mtime1 = r->modificationTime();
size1 = r->size();
//.........这里部分代码省略.........
示例3: if
void
Api_v1_5::playback( QxtWebRequestEvent* event, const QString& command )
{
if ( command == "next")
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "next", Qt::QueuedConnection ) , "Skipping to the next track failed." );
}
else if ( command == "previous" )
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "previous", Qt::QueuedConnection ), "Rewinding to the previous track failed." );
}
else if ( command == "playpause" )
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "playPause", Qt::QueuedConnection ), "Play/Pause failed." );
}
else if ( command == "play" )
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "play", Qt::QueuedConnection ), "Starting the playback failed." );
}
else if ( command == "pause" )
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "pause", Qt::QueuedConnection ), "Pausing the current track failed." );
}
else if ( command == "stop" )
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "stop", Qt::QueuedConnection ), "Stopping the current track failed." );
}
else if ( command == "lowervolume" )
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "lowerVolume", Qt::QueuedConnection ), "Lowering volume failed." );
}
else if ( command == "raisevolume" )
{
JSON_REPLY( QMetaObject::invokeMethod( AudioEngine::instance(), "raiseVolume", Qt::QueuedConnection ), "Raising volume failed." );
}
else if ( command == "currenttrack" )
{
QByteArray json;
Tomahawk::result_ptr currentTrack = AudioEngine::instance()->currentTrack();
if ( currentTrack.isNull() )
{
json = "{ \"playing\": false }";
}
else
{
QVariantMap trackInfo;
trackInfo.insert( "playing", true );
trackInfo.insert( "paused", AudioEngine::instance()->isPaused() );
trackInfo.insert( "position", AudioEngine::instance()->currentTime() / 1000 );
trackInfo.insert( "bitrate", currentTrack->bitrate() );
if ( currentTrack->resolvedBy() ) {
QString resolverName = currentTrack->resolvedBy()->name();
trackInfo.insert( "resolvedBy", resolverName );
} else {
trackInfo.insert( "resolvedBy", "<unknown resolver>" );
}
trackInfo.insert( "score", currentTrack->score() );
trackInfo.insert( "album", currentTrack->track()->album() );
trackInfo.insert( "albumpos", currentTrack->track()->albumpos() );
trackInfo.insert( "artist", currentTrack->track()->artist() );
trackInfo.insert( "duration", currentTrack->track()->duration() );
trackInfo.insert( "track", currentTrack->track()->track() );
bool ok;
json = TomahawkUtils::toJson( trackInfo, &ok );
Q_ASSERT( ok );
}
QxtWebPageEvent * e = new QxtWebPageEvent( event->sessionID, event->requestID, json );
e->headers.insert( "Access-Control-Allow-Origin", "*" );
e->contentType = "application/json";
m_service->postEvent( e );
}
else if ( command == "volume" )
{
QByteArray json = QString( "{ \"result\": \"ok\", \"volume\": %1}" ).arg( AudioEngine::instance()->volume() ).toUtf8();
QxtWebPageEvent * e = new QxtWebPageEvent( event->sessionID, event->requestID, json );
e->headers.insert( "Access-Control-Allow-Origin", "*" );
e->contentType = "application/json";
m_service->postEvent( e );
}
else
{
m_service->sendJsonError( event, "No such playback command." );
}
}