2004-02-24 00:41:20 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
2007-04-05 05:22:33 +02:00
|
|
|
* Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
|
2004-02-24 00:41:20 +01:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2008-10-31 09:19:53 +01:00
|
|
|
#ifndef MPD_PLAYLIST_H
|
|
|
|
#define MPD_PLAYLIST_H
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-08-28 20:01:08 +02:00
|
|
|
#include "locate.h"
|
2009-01-22 23:40:11 +01:00
|
|
|
#include "queue.h"
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
#include <stdbool.h>
|
2008-10-08 10:49:11 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2007-05-16 14:02:10 +02:00
|
|
|
#define PLAYLIST_COMMENT '#'
|
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
struct client;
|
|
|
|
|
2008-09-07 13:39:31 +02:00
|
|
|
enum playlist_result {
|
|
|
|
PLAYLIST_RESULT_SUCCESS,
|
|
|
|
PLAYLIST_RESULT_ERRNO,
|
2008-10-15 22:35:13 +02:00
|
|
|
PLAYLIST_RESULT_DENIED,
|
2008-09-07 13:39:31 +02:00
|
|
|
PLAYLIST_RESULT_NO_SUCH_SONG,
|
|
|
|
PLAYLIST_RESULT_NO_SUCH_LIST,
|
|
|
|
PLAYLIST_RESULT_LIST_EXISTS,
|
|
|
|
PLAYLIST_RESULT_BAD_NAME,
|
|
|
|
PLAYLIST_RESULT_BAD_RANGE,
|
|
|
|
PLAYLIST_RESULT_NOT_PLAYING,
|
2009-01-18 16:15:45 +01:00
|
|
|
PLAYLIST_RESULT_TOO_LARGE,
|
|
|
|
PLAYLIST_RESULT_DISABLED,
|
2008-09-07 13:39:31 +02:00
|
|
|
};
|
|
|
|
|
2007-05-16 14:02:10 +02:00
|
|
|
typedef struct _Playlist {
|
2009-01-23 00:06:53 +01:00
|
|
|
/**
|
|
|
|
* The song queue - it contains the "real" playlist.
|
|
|
|
*/
|
2009-01-22 23:40:11 +01:00
|
|
|
struct queue queue;
|
|
|
|
|
2009-01-23 00:09:26 +01:00
|
|
|
/**
|
|
|
|
* This value is true if the player is currently playing (or
|
|
|
|
* should be playing).
|
|
|
|
*/
|
|
|
|
bool playing;
|
|
|
|
|
2009-01-23 00:06:53 +01:00
|
|
|
/**
|
|
|
|
* The "current song pointer". This is the song which is
|
|
|
|
* played when we get the "play" command. It is also the song
|
|
|
|
* which is currently being played.
|
|
|
|
*/
|
2007-05-16 14:02:10 +02:00
|
|
|
int current;
|
2009-01-23 00:06:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The "next" song to be played, when the current one
|
2009-01-23 07:33:15 +01:00
|
|
|
* finishes. The decoder thread may start decoding and
|
|
|
|
* buffering it, while the "current" song is still playing.
|
|
|
|
*
|
|
|
|
* This variable is only valid if #playing is true.
|
2009-01-23 00:06:53 +01:00
|
|
|
*/
|
2007-05-16 14:02:10 +02:00
|
|
|
int queued;
|
|
|
|
} Playlist;
|
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
extern bool playlist_saveAbsolutePaths;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
extern unsigned playlist_max_length;
|
2008-01-26 21:20:59 +01:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
void initPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
void finishPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-07-31 01:32:47 +02:00
|
|
|
void readPlaylistState(FILE *);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-07-31 01:32:47 +02:00
|
|
|
void savePlaylistState(FILE *);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-08-26 08:27:16 +02:00
|
|
|
void clearPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-12-30 19:14:13 +01:00
|
|
|
#ifndef WIN32
|
2008-10-15 22:35:13 +02:00
|
|
|
/**
|
|
|
|
* Appends a local file (outside the music database) to the playlist,
|
|
|
|
* but only if the file's owner is equal to the specified uid.
|
|
|
|
*/
|
|
|
|
enum playlist_result
|
2008-10-23 07:19:46 +02:00
|
|
|
playlist_append_file(const char *path, int uid, unsigned *added_id);
|
2008-12-30 19:14:13 +01:00
|
|
|
#endif
|
2008-10-15 22:35:13 +02:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result addToPlaylist(const char *file, unsigned *added_id);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
enum playlist_result
|
2008-10-23 07:19:46 +02:00
|
|
|
addSongToPlaylist(struct song *song, unsigned *added_id);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-09-07 14:02:52 +02:00
|
|
|
void showPlaylist(struct client *client);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result deleteFromPlaylist(unsigned song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result deleteFromPlaylistById(unsigned song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-01-10 17:39:49 +01:00
|
|
|
/**
|
|
|
|
* Send detailed information about a range of songs in the playlist to
|
|
|
|
* a client.
|
|
|
|
*
|
|
|
|
* @param client the client which has requested information
|
|
|
|
* @param start the index of the first song (including)
|
|
|
|
* @param end the index of the last song (excluding)
|
|
|
|
*/
|
|
|
|
enum playlist_result
|
|
|
|
playlistInfo(struct client *client, unsigned start, unsigned end);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-09-07 13:53:55 +02:00
|
|
|
enum playlist_result playlistId(struct client *client, int song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2008-08-26 08:27:16 +02:00
|
|
|
void stopPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-01-23 00:10:50 +01:00
|
|
|
enum playlist_result playPlaylist(int song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-01-23 00:10:50 +01:00
|
|
|
enum playlist_result playPlaylistById(int song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2008-08-26 08:27:16 +02:00
|
|
|
void nextSongInPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
void syncPlayerAndPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-08-26 08:27:16 +02:00
|
|
|
void previousSongInPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-09-07 13:39:31 +02:00
|
|
|
void shufflePlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-09-07 13:39:31 +02:00
|
|
|
enum playlist_result savePlaylist(const char *utf8file);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
void
|
|
|
|
deleteASongFromPlaylist(const struct song *song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result moveSongInPlaylist(unsigned from, int to);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result moveSongInPlaylistById(unsigned id, int to);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result swapSongsInPlaylist(unsigned song1, unsigned song2);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result swapSongsInPlaylistById(unsigned id1, unsigned id2);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-01-04 18:59:32 +01:00
|
|
|
enum playlist_result loadPlaylist(const char *utf8file);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
bool getPlaylistRepeatStatus(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
void setPlaylistRepeatStatus(bool status);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
bool getPlaylistRandomStatus(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
void setPlaylistRandomStatus(bool status);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
int getPlaylistCurrentSong(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
unsigned getPlaylistSongId(unsigned song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
int getPlaylistLength(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
unsigned long getPlaylistVersion(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result seekSongInPlaylist(unsigned song, float seek_time);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-23 07:19:46 +02:00
|
|
|
enum playlist_result seekSongInPlaylistById(unsigned id, float seek_time);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
void playlistVersionChange(void);
|
2004-06-05 03:14:37 +02:00
|
|
|
|
2008-09-29 15:49:29 +02:00
|
|
|
int playlistChanges(struct client *client, uint32_t version);
|
2004-03-10 11:00:47 +01:00
|
|
|
|
2008-09-29 15:49:29 +02:00
|
|
|
int playlistChangesPosId(struct client *client, uint32_t version);
|
2006-04-23 13:10:41 +02:00
|
|
|
|
2009-01-23 16:22:43 +01:00
|
|
|
void
|
|
|
|
searchForSongsInPlaylist(struct client *client,
|
|
|
|
unsigned numItems, const LocateTagItem *items);
|
2007-02-24 03:00:03 +01:00
|
|
|
|
2009-01-23 16:22:43 +01:00
|
|
|
void
|
|
|
|
findSongsInPlaylist(struct client *client,
|
|
|
|
unsigned numItems, const LocateTagItem *items);
|
2007-02-24 03:00:03 +01:00
|
|
|
|
2008-09-07 13:37:04 +02:00
|
|
|
int is_valid_playlist_name(const char *utf8path);
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
#endif
|