Design overview: PlaylistManager

Bart Cerneels bart.cerneels at kde.org
Sat May 2 08:42:53 CEST 2009


2009/4/26 Bart Cerneels <bart.cerneels at kde.org>:
> On Sun, Apr 26, 2009 at 1:26 PM, Bart Cerneels <bart.cerneels at kde.org> wrote:
>> This is an overview of the
>> PlaylistManager/Meta::Playlist/Synchronization in Amarok as a
>> preparation for the Amarok DevSprint in Berlin, May 1.
>>
>> Classes (function):
>> - Meta::Playlist (abstract base of all playlists)
>> - PlaylistManager (Facility for managing PlaylistProviders registered
>> by other parts of the application, plugins or scripts)
>> - PlaylistProvider (abstract base that gives playlists, description
>> and friendlyname for once playlist category)
>>
>> Related classes in browsers/playlistbrowser not covered in this overview
>> - PodcastCategory/PodcastModel
>> - PlaylistCategory/UserPlaylistModel
>> - PlaylistsInGroupsProxy
>> ...
>>
>> Next mail: functional overview
>>
>> Bart
>>
>
> Functional overview:
>
> *PlaylistManager
>
> During startup, plugin loading or script execution a PlaylistProvider
> gets initialized and registered with the PlaylistManager.
> During registration a Provider gets assigned to a certain playlist Category.
> There are a number of Categories defined:
> enum PlaylistCategory
>        {
>            CurrentPlaylist = 1,
>            UserPlaylist,
>            PodcastChannel,
>            Dynamic,
>            SmartPlaylist,
>            Custom
>        };
> CurrentPlaylist: (unused) gives access to the current list of tracks
> in The Playlist.
>
> UserPlaylist: manually created by the user in Amarok, his iPod, on
> Ampache, Last.fm, ...
>
> PodcastChannel: An auto-updating playlist based on an rss feed.
> PodcastEpisodes are derived from Meta::Track
>
> Dynamic & SmartPlaylist: (unused) all the auto-generated playlists
> based on statistics, recommendations, ... i.e. Biases
>
> Custom: (unused) offset in the enum used for dynamically registered classes.
>
> Each Category has a translated user-friendly name to identify the type
> of playlist.
> Using "int PlaylistManager::registerCustomCategory( const QString
> &name )" new Categories can be created by scripts and plugins.
>
> *PlaylistProvider
>
> -> next mail
>

* PlaylistProviders:
The abstract class PlaylistProvider has only 3 functions:

QString prettyName(): returns a translated string to identify this Provider.

int category(): one of the values of the PlaylistCategory enum or a
dynamically registered value.

Meta::PlaylistList playlists(): all the playlists this provider has.

There deliberately is no PlaylistGroup class. It rather relies on
labels, which is a broader concept then folders yet allows folders to
be simulated. Take GMail labels as an example. Labels are also more
powerful: a playlist can have multiple labels, yet it can be in only
one folder.

This class should get extended to provide more functionality, like
custom actions for a given playlist.

* More about PlaylistManager:
For each of the default playlist categories there is a default implementation:
- UserPlaylistProvider *defaultUserPlaylists(): SqlUserPlaylistProvider
- PodcastProvider *defaultPodcasts(): SqlPodcastProvider
- Dynamic playlists don't have a provider yet, since it has not been
converted to the PlaylistManager system.

The PlaylistManager also handles the saving to persistent storage of
the current tracks. Currently it will always save to the default one,
but it's possible to offer the user the choice if multiple providers
for the UserPlaylist category are available.

It also loads and saves playlist files. This has been a hack to add
playlist-file support quickly, but ideally it should be transformed
into a proper PlaylistFileProvider.

next: How does this tie in to the PlaylistBrowser?


More information about the Amarok-devel mailing list