Commit 7d88d07c authored by Matěj Laitl's avatar Matěj Laitl
Browse files

AmarokPlaylistScript: play all media in {add,play}Media(), add playMediaList()

No need to convert to tracks (this way it excluded playlists),
PlaylistController is good enough to read all kinds of urls including
playlists.

Add playMediaList() method for symmetry with addMediaList() when at it.

We thought it worked for other than .m3u playlists, but it was by
chance becasce CollectionManager::trackForUrl() returned something
(probably the first track) for other playlists.

BUG: 232697
FIXED-IN: 2.6
parent 728680ee
......@@ -4,10 +4,13 @@ Amarok ChangeLog
VERSION 2.6
CHANGES:
* Add Amarok.Playlist.playMediaList() script bindings for API symmetry.
* Building the spectrum analyzer applet can now be disabled with a CMake
argument.
BUGFIXES:
* Fix Amarok.Playlist.{add,play}Media() and addMediaList() Qt script
bindings methods not being able to add playlists. (BR 232697)
* Add "Last Played" back to the Edit Filter dialog. (BR 302746)
* Correct rounding for rating in Track Details dialog. (BR 273363)
* Fix Context view not being fully formed on startup. (BR 292895)
......
......@@ -64,17 +64,16 @@ namespace AmarokScript
void AmarokPlaylistScript::addMedia( const QUrl &url )
{
Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( url );
The::playlistController()->insertOptioned( track, Playlist::Append );
QList<KUrl> list = QList<KUrl>() << url;
The::playlistController()->insertOptioned( list, Playlist::Append );
}
void AmarokPlaylistScript::addMediaList( const QVariantList &urls )
{
KUrl::List list;
QList<KUrl> list;
foreach( const QVariant &url, urls )
list << url.toUrl();
Meta::TrackList tracks = CollectionManager::instance()->tracksForUrls( list );
The::playlistController()->insertOptioned( tracks, Playlist::Append );
The::playlistController()->insertOptioned( list, Playlist::Append );
}
void AmarokPlaylistScript::clearPlaylist()
......@@ -89,9 +88,16 @@ namespace AmarokScript
void AmarokPlaylistScript::playMedia( const QUrl &url )
{
Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( url );
if( track )
The::playlistController()->insertOptioned( track, Playlist::DirectPlay | Playlist::Unique );
QList<KUrl> list = QList<KUrl>() << url;
The::playlistController()->insertOptioned( list, Playlist::DirectPlay );
}
void AmarokPlaylistScript::playMediaList(const QVariantList& urls)
{
QList<KUrl> list;
foreach( const QVariant &url, urls )
list << url.toUrl();
The::playlistController()->insertOptioned( list, Playlist::DirectPlay );
}
void AmarokPlaylistScript::removeCurrentTrack()
......
......@@ -46,6 +46,7 @@ namespace AmarokScript
void clearPlaylist();
void playByIndex( int index );
void playMedia( const QUrl &url );
void playMediaList( const QVariantList &urls );
void removeCurrentTrack();
void removeByIndex( int index );
void savePlaylist( const QString& path );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment