From 73c246dfa2bac8f9e8a48f033fc3a032adf7b54f Mon Sep 17 00:00:00 2001 From: nhnielsen Date: Mon, 24 Sep 2007 06:57:19 +0000 Subject: [PATCH] And for the grand finale, port XSPF support. This has also not been tested with an actual xspf file git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/extragear/multimedia/amarok@716191 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/playlist/PlaylistLoader.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ src/playlist/PlaylistLoader.h | 1 + 2 files changed, 43 insertions(+) diff --git a/src/playlist/PlaylistLoader.cpp b/src/playlist/PlaylistLoader.cpp index 9d3f6947b..102e3c0a9 100644 --- a/src/playlist/PlaylistLoader.cpp +++ b/src/playlist/PlaylistLoader.cpp @@ -20,6 +20,7 @@ #include "PlaylistModel.h" #include "statusbar.h" #include "TheInstances.h" +#include "xspfplaylist.h" #include @@ -561,5 +562,46 @@ QTime PlaylistLoader::stringToTime(const QString& timeString) return QTime(); } +bool +PlaylistLoader::loadXSPF( QTextStream &stream ) +{ + XSPFPlaylist* doc = new XSPFPlaylist( stream ); + + XSPFtrackList trackList = doc->trackList(); + + TrackList tracks; + oldForeachType( XSPFtrackList, trackList ) + { + KUrl location = (*it).location; + QString artist = (*it).creator; + QString title = (*it).title; + QString album = (*it).album; + + if( location.isEmpty() || ( location.isLocalFile() && !QFile::exists( location.url() ) ) ) + { + + TrackPtr trackPtr = CollectionManager::instance()->trackForUrl( location ); + tracks.append( trackPtr ); + } + else + { + debug() << location << ' ' << artist << ' ' << title << ' ' << album; + + TrackPtr trackPtr = CollectionManager::instance()->trackForUrl( location ); + trackPtr->setTitle( title ); + trackPtr->setArtist( artist ); + trackPtr->setAlbum( album ); + trackPtr->setComment( (*it).annotation ); + tracks.append( trackPtr ); + + } + } + + delete doc; + + The::playlistModel()->insertOptioned( tracks, Playlist::Append ); + return true; +} + #include "PlaylistLoader.moc" diff --git a/src/playlist/PlaylistLoader.h b/src/playlist/PlaylistLoader.h index ad8f3410a..1dbd41944 100644 --- a/src/playlist/PlaylistLoader.h +++ b/src/playlist/PlaylistLoader.h @@ -67,6 +67,7 @@ private: bool loadRealAudioRam( QTextStream& ); bool loadASX( QTextStream& ); bool loadSMIL( QTextStream& ); + bool loadXSPF( QTextStream& ); Format getFormat( const KUrl &path ); void handleByFormat( QTextStream &stream, Format format); -- 2.11.4.GIT