本文整理汇总了C++中tomahawk::result_ptr::resolvedBy方法的典型用法代码示例。如果您正苦于以下问题:C++ result_ptr::resolvedBy方法的具体用法?C++ result_ptr::resolvedBy怎么用?C++ result_ptr::resolvedBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tomahawk::result_ptr
的用法示例。
在下文中一共展示了result_ptr::resolvedBy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tDebug
void
AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{
Q_D( AudioEngine );
tDebug( LOGEXTRA ) << Q_FUNC_INFO << ( result.isNull() ? QString() : result->url() );
if ( !result )
{
stop();
return;
}
// We do this to stop the audio as soon as a user activated another track
// If we don't block the audioOutput signals, the state change will trigger
// loading yet another track
d->audioOutput->blockSignals( true );
d->audioOutput->stop();
d->audioOutput->blockSignals( false );
setCurrentTrack( result );
ScriptJob* job = result->resolvedBy()->getStreamUrl( result );
connect( job, SIGNAL( done( QVariantMap ) ), SLOT( gotStreamUrl( QVariantMap ) ) );
job->setProperty( "result", QVariant::fromValue( result ) );
job->start();
}
示例2: 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." );
}
}