80 lines
1.5 KiB
C
80 lines
1.5 KiB
C
/*
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/playlist.h>
|
|
#include <core/playlists/system.h>
|
|
|
|
|
|
void playlist_init(struct queue_ops *ops)
|
|
{
|
|
pl_system_init(ops);
|
|
}
|
|
|
|
void playlist_deinit()
|
|
{
|
|
pl_system_deinit();
|
|
}
|
|
|
|
bool playlist_add(const gchar *name, struct track *track)
|
|
{
|
|
if (!track)
|
|
return false;
|
|
return pl_system.pl_add_track(name, track);
|
|
}
|
|
|
|
bool playlist_remove(const gchar *name, struct track *track)
|
|
{
|
|
if (!track)
|
|
return false;
|
|
return pl_system.pl_remove_track(name, track);
|
|
}
|
|
|
|
void playlist_update(const gchar *name)
|
|
{
|
|
pl_system.pl_update(name);
|
|
}
|
|
|
|
bool playlist_has(const gchar *name, struct track *track)
|
|
{
|
|
struct queue *queue = pl_system.pl_get_queue(name);
|
|
if (!track || !queue)
|
|
return false;
|
|
return queue_has(queue, track);
|
|
}
|
|
|
|
unsigned int playlist_size(const gchar *name)
|
|
{
|
|
struct queue *queue = pl_system.pl_get_queue(name);
|
|
return queue ? queue_size(queue) : 0;
|
|
}
|
|
|
|
void playlist_set_random(const gchar *name, bool enabled)
|
|
{
|
|
pl_system.pl_set_flag(name, Q_RANDOM, enabled);
|
|
}
|
|
|
|
bool playlist_get_random(const gchar *name)
|
|
{
|
|
return queue_has_flag(playlist_get_queue(name), Q_RANDOM);
|
|
}
|
|
|
|
void playlist_sort(const gchar *name, enum compare_t sort, bool reset)
|
|
{
|
|
pl_system.pl_sort(name, sort, reset);
|
|
}
|
|
|
|
struct track *playlist_next(void)
|
|
{
|
|
return queue_next(playlist_get_queue("Collection"));
|
|
}
|
|
|
|
struct track *playlist_prev(void)
|
|
{
|
|
return queue_next(playlist_get_queue("History"));
|
|
}
|
|
|
|
struct queue *playlist_get_queue(const gchar *name)
|
|
{
|
|
return pl_system.pl_get_queue(name);
|
|
}
|