1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

Fixed seeking for HTTP streams without headers, e.g. Spotify (see #453).

This commit is contained in:
Christian Muehlhaeuser
2016-04-14 00:57:00 +02:00
parent ceab0f9cf2
commit bf28f6856e

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2015, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2016, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org> * Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Teo Mrnjavac <teo@kde.org> * Copyright 2013, Teo Mrnjavac <teo@kde.org>
* *
@@ -604,6 +604,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
job->start(); job->start();
} }
void void
AudioEngine::gotStreamUrl( const QVariantMap& data ) AudioEngine::gotStreamUrl( const QVariantMap& data )
{ {
@@ -611,14 +612,17 @@ AudioEngine::gotStreamUrl( const QVariantMap& data )
QVariantMap headers = data[ "headers" ].toMap(); QVariantMap headers = data[ "headers" ].toMap();
Tomahawk::result_ptr result = sender()->property( "result" ).value<result_ptr>(); Tomahawk::result_ptr result = sender()->property( "result" ).value<result_ptr>();
if ( streamUrl.isEmpty() || !( TomahawkUtils::isHttpResult( streamUrl ) || TomahawkUtils::isHttpsResult( streamUrl ) ) ) if ( streamUrl.isEmpty() || headers.isEmpty() ||
!( TomahawkUtils::isHttpResult( streamUrl ) || TomahawkUtils::isHttpsResult( streamUrl ) ) )
{ {
// Not an http(s) or RTMP URL, get IO device // We can't supply custom headers to VLC - but prefer using its HTTP streaming due to improved seeking ability
// Not an RTMP or HTTP-with-headers URL, get IO device
QSharedPointer< QIODevice > sp; QSharedPointer< QIODevice > sp;
performLoadIODevice( result, streamUrl ); performLoadIODevice( result, streamUrl );
} }
else else
{ {
// We need our own QIODevice for streaming
// TODO: just make this part of the http(s) IoDeviceFactory (?) // TODO: just make this part of the http(s) IoDeviceFactory (?)
QUrl url = QUrl::fromEncoded( streamUrl.toUtf8() ); QUrl url = QUrl::fromEncoded( streamUrl.toUtf8() );
QNetworkRequest req( url ); QNetworkRequest req( url );
@@ -646,6 +650,7 @@ AudioEngine::gotStreamUrl( const QVariantMap& data )
sender()->deleteLater(); sender()->deleteLater();
} }
void void
AudioEngine::gotRedirectedStreamUrl( const Tomahawk::result_ptr& result, NetworkReply* reply ) AudioEngine::gotRedirectedStreamUrl( const Tomahawk::result_ptr& result, NetworkReply* reply )
{ {