mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 19:37:09 +02:00
Add getStreamUrl translation step in AudioEngine
This commit is contained in:
@@ -17,8 +17,24 @@
|
||||
*/
|
||||
#include "ResultProvider.h"
|
||||
|
||||
#include "Result.h"
|
||||
#include "resolvers/SyncScriptJob.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
ResultProvider::~ResultProvider()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ScriptJob*
|
||||
ResultProvider::getStreamUrl( const result_ptr& result )
|
||||
{
|
||||
QUrl url = result->url();
|
||||
|
||||
QVariantMap data;
|
||||
data[ "result" ] = QVariant::fromValue( result );
|
||||
data[ "url" ] = url;
|
||||
|
||||
return new SyncScriptJob( data );
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#define TOMAHAWK_RESULTPROVIDER_H
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "Typedefs.h"
|
||||
|
||||
class QPixmap;
|
||||
class QString;
|
||||
@@ -27,6 +28,7 @@ class QSize;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
class ScriptJob;
|
||||
|
||||
class DLLEXPORT ResultProvider
|
||||
{
|
||||
@@ -35,6 +37,8 @@ public:
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual QPixmap icon( const QSize& size ) const = 0;
|
||||
|
||||
virtual ScriptJob* getStreamUrl( const result_ptr& result );
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "SourceList.h"
|
||||
#include "TomahawkSettings.h"
|
||||
#include "UrlHandler.h"
|
||||
#include "resolvers/ScriptJob.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
@@ -574,10 +575,21 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
|
||||
setCurrentTrack( result );
|
||||
|
||||
if ( !TomahawkUtils::isLocalResult( d->currentTrack->url() ) && !TomahawkUtils::isHttpResult( d->currentTrack->url() )
|
||||
&& !TomahawkUtils::isRtmpResult( d->currentTrack->url() ) )
|
||||
ScriptJob* job = result->resolvedBy()->getStreamUrl( result );
|
||||
connect( job, SIGNAL( done( QVariantMap ) ), SLOT( gotStreamUrl( QVariantMap ) ) );
|
||||
job->start();
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::gotStreamUrl( const QVariantMap& data )
|
||||
{
|
||||
QString url = data[ "url" ].toString();
|
||||
result_ptr result = data[ "result" ].value<result_ptr>();
|
||||
|
||||
if ( !TomahawkUtils::isLocalResult( url ) && !TomahawkUtils::isHttpResult( url )
|
||||
&& !TomahawkUtils::isRtmpResult( url ) )
|
||||
{
|
||||
performLoadIODevice( d->currentTrack, d->currentTrack->url() );
|
||||
performLoadIODevice( result, url );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -180,6 +180,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void loadTrack( const Tomahawk::result_ptr& result ); //async!
|
||||
void gotStreamUrl( const QVariantMap& data );
|
||||
void performLoadIODevice( const Tomahawk::result_ptr& result, const QString& url ); //only call from loadTrack kthxbi
|
||||
void performLoadTrack( const Tomahawk::result_ptr result, const QString url, QSharedPointer< QIODevice > io ); //only call from loadTrack or performLoadIODevice kthxbi
|
||||
void loadPreviousTrack();
|
||||
|
Reference in New Issue
Block a user