class Xmms::Playlist

Constants

ACTIVE_NAME
ADD
CLEAR
INSERT
MOVE
REMOVE
SHUFFLE
SORT
UPDATE

Public Class Methods

pl = Xmms::Playlist.new(xc, [name]) click to toggle source

Initializes a new Xmms::Playlist using the playlist named name and the Xmms::Client instance xc. Xmms::Client#playlist is a useful shortcut. name is is the name of the playlist and the active playlist will be used if it is not specified. Raises PlaylistError if the playlist name is invalid.

static VALUE
c_init (int argc, VALUE *argv, VALUE self)
{
        RbPlaylist *pl = NULL;
        VALUE name, xmms = Qnil;

        Data_Get_Struct (self, RbPlaylist, pl);

        rb_scan_args (argc, argv, "11", &xmms, &name);

        /* FIXME: Check type! */
        pl->xmms = xmms;

        if (NIL_P (name))
                pl->name_value = rb_str_new2 (XMMS_ACTIVE_PLAYLIST);
        else
                pl->name_value = rb_str_dup (name);

        OBJ_FREEZE (pl->name_value);

        pl->name = StringValuePtr (pl->name_value);

        return self;
}

Public Instance Methods

add_collection(coll [, order]) → result click to toggle source

Adds the collection coll to the playlist.

static VALUE
c_add_collection (int argc, VALUE *argv, VALUE self)
{
        PLAYLIST_METHOD_HANDLER_HEADER

        VALUE rbcoll, order = Qnil;
        xmmsv_t *corder = NULL;
        xmmsc_coll_t *coll;

        rb_scan_args (argc, argv, "11", &rbcoll, &order);

        coll = FROM_XMMS_CLIENT_COLLECTION (rbcoll);

        if (!NIL_P (order))
                corder = parse_string_array2 (order);

        res = xmmsc_playlist_add_collection (xmms->real, pl->name,
                                             coll, corder);

        if (corder)
                xmmsv_unref (corder);

        PLAYLIST_METHOD_HANDLER_FOOTER
}
add_entry(arg) → result click to toggle source

Adds an entry to the playlist. arg can be either a URL or an id.

static VALUE
c_add_entry (VALUE self, VALUE arg)
{
        int32_t id;

        PLAYLIST_METHOD_HANDLER_HEADER

        if (!NIL_P (rb_check_string_type (arg)))
                res = xmmsc_playlist_add_url (xmms->real, pl->name,
                                              StringValuePtr (arg));
        else {
                id = check_int32 (arg);
                res = xmmsc_playlist_add_id (xmms->real, pl->name, id);
        }

        PLAYLIST_METHOD_HANDLER_FOOTER
}
clear → result click to toggle source

Clears the playlist.

static VALUE
c_clear (VALUE self)
{
        PLAYLIST_METHOD_ADD_HANDLER (clear)
}
current_pos → result click to toggle source

Retrieves the current position of the playlist. May raise an Xmms::Result::ValueError exception if the current position is undefined.

static VALUE
c_current_pos (VALUE self)
{
        PLAYLIST_METHOD_ADD_HANDLER (current_pos)
}
entries → result click to toggle source

Retrieves an array containing ids for each position of the playlist.

static VALUE
c_list_entries (VALUE self)
{
        PLAYLIST_METHOD_ADD_HANDLER (list_entries)
}
insert_entry(pos, arg) → result click to toggle source

Inserts an entry to the current playlist at position pos in the playlist. arg can be either a URL or an id.

static VALUE
c_insert_entry (VALUE self, VALUE pos, VALUE arg)
{
        int32_t id;
        int32_t ipos;

        PLAYLIST_METHOD_HANDLER_HEADER

        ipos = check_int32 (pos);

        if (!NIL_P (rb_check_string_type (arg)))
                res = xmmsc_playlist_insert_url (xmms->real, pl->name,
                                                 ipos, StringValuePtr (arg));
        else {
                id = check_int32 (arg);
                res = xmmsc_playlist_insert_id (xmms->real, pl->name,
                                                ipos, id);
        }

        PLAYLIST_METHOD_HANDLER_FOOTER
}
load → result click to toggle source

Loads the playlist as the current active playlist.

static VALUE
c_load (VALUE self)
{
        PLAYLIST_METHOD_ADD_HANDLER (load);
}
playlist_move_entry(current_pos, new_pos) → result click to toggle source

Moves the entry at current_pos to new_pos in the playlist.

static VALUE
c_move_entry (VALUE self, VALUE cur_pos, VALUE new_pos)
{
        PLAYLIST_METHOD_ADD_HANDLER_INT_INT (move_entry, cur_pos, new_pos)
}
name → string click to toggle source

Returns the name of the playlist in the medialib as a String.

static VALUE
c_name (VALUE self)
{
        RbPlaylist *pl = NULL;

        Data_Get_Struct (self, RbPlaylist, pl);

        return pl->name_value;
}
radd(path) → result click to toggle source

Recursively imports all media files under path to the playlist.

static VALUE
c_radd (VALUE self, VALUE path)
{
        PLAYLIST_METHOD_ADD_HANDLER_STR (radd, path);
}
remove → result click to toggle source

Removes the playlist from the medialib.

static VALUE
c_remove (VALUE self)
{
        PLAYLIST_METHOD_ADD_HANDLER (remove);
}
remove_entry(pos) → result click to toggle source

Removes the entry at pos from the playlist.

static VALUE
c_remove_entry (VALUE self, VALUE pos)
{
        PLAYLIST_METHOD_ADD_HANDLER_INT (remove_entry, pos)
}
rinsert(pos, path) → result click to toggle source

Recursively imports all media files under path at position pos in the playlist.

static VALUE
c_rinsert (VALUE self, VALUE pos, VALUE path)
{
        PLAYLIST_METHOD_ADD_HANDLER_INT_STR (rinsert, pos, path);
}
shuffle → result click to toggle source

Shuffles the playlist.

static VALUE
c_shuffle (VALUE self)
{
        PLAYLIST_METHOD_ADD_HANDLER (shuffle)
}
sort(properties) → result click to toggle source

Sorts the playlist on properties, which is an array of medialib properties such as [“title”, “artist”].

static VALUE
c_sort (VALUE self, VALUE props)
{
        xmmsv_t *cprops;
        PLAYLIST_METHOD_HANDLER_HEADER

        cprops = parse_string_array2 (props);
        res = xmmsc_playlist_sort (xmms->real, pl->name, cprops);
        xmmsv_unref (cprops);

        PLAYLIST_METHOD_HANDLER_FOOTER
}