Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
void
ScriptCommand_AllTracks::exec()
{
    Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
    if ( collection == 0 )
    {
        reportFailure();
        return;
    }

    ScriptJob* job;
    if( m_album )
    {
        QVariantMap arguments;
        arguments[ "artist" ] = m_album->artist()->name();
        arguments[ "album" ] = m_album->name();

        job = collection->scriptObject()->invoke( "albumTracks", arguments );
    }
    else
    {
        job = collection->scriptObject()->invoke( "tracks" );
    }


    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onTracksJobDone( QVariantMap ) ), Qt::QueuedConnection );
    job->start();
}
Exemplo n.º 3
0
void
ScriptInfoPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
    Q_D( ScriptInfoPlugin );

    QVariantMap arguments;
    arguments[ "type" ] = requestData.type;
    arguments[ "criteria" ] = convertInfoStringHashToQVariantMap( criteria );

    ScriptJob* job = m_scriptObject->invoke( "_notInCache", arguments );
    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onNotInCacheRequestDone( QVariantMap ) ) );
    d->requestDataCache[ job->id().toInt() ] = requestData;
    d->criteriaCache[ job->id().toInt() ] = criteria;

    job->start();
}
Exemplo n.º 4
0
void
ScriptInfoPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{
    Q_D( ScriptInfoPlugin );


    QVariantMap arguments;
    arguments[ "type" ] = requestData.type;
    arguments[ "data" ] = convertInfoStringHashToQVariantMap( requestData.input.value<Tomahawk::InfoSystem::InfoStringHash>() );

    ScriptJob* job = m_scriptObject->invoke( "_getInfo", arguments );
    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onGetInfoRequestDone( QVariantMap ) ) );

    d->requestDataCache[ job->id().toInt() ] = requestData;
    job->start();
}
void
ScriptCommand_AllArtists::exec()
{
    Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
    Q_ASSERT( collection );

    QVariantMap arguments;
    if ( !m_filter.isEmpty() )
    {
        arguments[ "filter" ] = m_filter;
    }

    ScriptJob* job = collection->scriptObject()->invoke( "artists", arguments );
    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onArtistsJobDone( QVariantMap ) ), Qt::QueuedConnection );
    job->start();
}