1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2018 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
24 #include <vlc_common.h>
25 #include <vlc_vector.h>
27 typedef struct vlc_playlist_item vlc_playlist_item_t
;
30 * \defgroup playlist_randomizer Playlist randomizer helper
35 * Playlist helper to manage random playback.
37 * See randomizer.c for implementation details.
40 struct VLC_VECTOR(vlc_playlist_item_t
*) items
;
41 unsigned short xsubi
[3]; /* random state */
49 * Initialize an empty randomizer.
52 randomizer_Init(struct randomizer
*randomizer
);
55 * Destroy a randomizer.
58 randomizer_Destroy(struct randomizer
*randomizer
);
61 * Enable or disable "loop" mode.
63 * This affects the behavior of prev/next.
66 randomizer_SetLoop(struct randomizer
*randomizer
, bool loop
);
69 * Return the number of items in the randomizer.
72 randomizer_Count(struct randomizer
*randomizer
);
75 * Start a new random cycle.
77 * The "history" is lost, and "next" can be called _n_ times if the randomizer
78 * contains _n_ items (when loop is disabled).
81 randomizer_Reshuffle(struct randomizer
*randomizer
);
84 * Indicate whether there is a previous item.
87 randomizer_HasPrev(struct randomizer
*randomizer
);
90 * Indicate whether there is a next item.
93 randomizer_HasNext(struct randomizer
*randomizer
);
96 * Peek the previous item (without changing the current one).
99 randomizer_PeekPrev(struct randomizer
*randomizer
);
102 * Peek the next item (without changing the current one).
104 vlc_playlist_item_t
*
105 randomizer_PeekNext(struct randomizer
*randomizer
);
108 * Go back to the previous item.
110 vlc_playlist_item_t
*
111 randomizer_Prev(struct randomizer
*randomizer
);
114 * Go back to the next item.
116 vlc_playlist_item_t
*
117 randomizer_Next(struct randomizer
*randomizer
);
120 * Force the selection of a specific item.
122 * This function should be called when the user requested to play a specific
123 * item in the playlist.
126 randomizer_Select(struct randomizer
*randomizer
,
127 const vlc_playlist_item_t
*item
);
130 * Add items to the randomizer.
132 * This function should be called when items are added to the playlist.
135 randomizer_Add(struct randomizer
*randomizer
, vlc_playlist_item_t
*items
[],
139 * Remove items from the randomizer.
141 * This function should be called when items are removed from the playlist.
144 randomizer_Remove(struct randomizer
*randomizer
,
145 vlc_playlist_item_t
*const items
[], size_t count
);
148 * Clear the randomizer.
151 randomizer_Clear(struct randomizer
*randomizer
);