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"
|
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,
|
|
|
|
PLAYLIST_RESULT_TOO_LARGE
|
|
|
|
};
|
|
|
|
|
2007-05-16 14:02:10 +02:00
|
|
|
typedef struct _Playlist {
|
2008-10-08 10:49:11 +02:00
|
|
|
struct song **songs;
|
2007-05-16 14:02:10 +02:00
|
|
|
/* holds version a song was modified on */
|
2008-09-29 15:49:29 +02:00
|
|
|
uint32_t *songMod;
|
2008-10-23 07:19:46 +02:00
|
|
|
unsigned *order;
|
|
|
|
unsigned *positionToId;
|
2007-05-16 14:02:10 +02:00
|
|
|
int *idToPosition;
|
2008-10-23 07:19:46 +02:00
|
|
|
unsigned length;
|
2007-05-16 14:02:10 +02:00
|
|
|
int current;
|
|
|
|
int queued;
|
2008-10-08 11:03:39 +02:00
|
|
|
bool repeat;
|
|
|
|
bool random;
|
2008-09-29 15:49:29 +02:00
|
|
|
uint32_t version;
|
2007-05-16 14:02:10 +02:00
|
|
|
} 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-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-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
|
|
|
|
2008-09-07 13:53:55 +02:00
|
|
|
enum playlist_result playlistInfo(struct client *client, int song);
|
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
|
|
|
|
2008-09-07 13:39:31 +02:00
|
|
|
enum playlist_result playPlaylist(int song, int stopOnError);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-09-07 13:39:31 +02:00
|
|
|
enum playlist_result playPlaylistById(int song, int stopOnError);
|
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
|
|
|
|
2008-09-07 13:57:26 +02:00
|
|
|
enum playlist_result loadPlaylist(struct client *client, 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
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
void playPlaylistIfPlayerStopped(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
|
|
|
|
2008-09-07 13:53:55 +02:00
|
|
|
int PlaylistInfo(struct client *client, const char *utf8file, int detail);
|
2006-03-26 15:46:05 +02:00
|
|
|
|
2008-09-07 13:53:55 +02:00
|
|
|
void searchForSongsInPlaylist(struct client *client,
|
2008-10-23 07:19:46 +02:00
|
|
|
unsigned numItems, LocateTagItem * items);
|
2007-02-24 03:00:03 +01:00
|
|
|
|
2008-09-07 13:53:55 +02:00
|
|
|
void findSongsInPlaylist(struct client *client,
|
2008-10-23 07:19:46 +02:00
|
|
|
unsigned numItems, 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
|