|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | public class Music.PlaybackManager : Object { |
7 | | - public signal bool ask_has_previous (); |
8 | | - public signal bool ask_has_next (bool repeat_all); |
9 | 7 | public signal void invalids_found (int count); |
10 | 8 |
|
11 | 9 | public AudioObject? current_audio { get; set; default = null; } |
@@ -187,61 +185,69 @@ public class Music.PlaybackManager : Object { |
187 | 185 | public void next (bool eos = false) { |
188 | 186 | direction = Direction.NEXT; |
189 | 187 | next_by_eos = eos; |
190 | | - uint position; |
191 | | - bool from_queue = queue_liststore.find (current_audio, out position); |
| 188 | + uint position = -1; |
| 189 | + queue_liststore.find (current_audio, out position); |
192 | 190 |
|
193 | | - if (from_queue && position != queue_liststore.get_n_items () - 1) { |
194 | | - current_audio = (AudioObject) queue_liststore.get_item (position + 1); |
195 | | - return; |
196 | | - } |
| 191 | + if (position != -1) { |
| 192 | + if (!next_by_eos) { |
| 193 | + if (position == queue_liststore.get_n_items () - 1) { |
| 194 | + current_audio = (AudioObject) queue_liststore.get_item (0); |
| 195 | + if (position == 0) { |
| 196 | + seek_to_progress (0); |
| 197 | + } |
| 198 | + } else { |
| 199 | + current_audio = (AudioObject) queue_liststore.get_item (position + 1); |
| 200 | + } |
197 | 201 |
|
198 | | - if (next_by_eos) { |
| 202 | + return; |
| 203 | + } |
199 | 204 | switch (settings.get_string ("repeat-mode")) { |
200 | 205 | case "disabled": |
| 206 | + if (position == queue_liststore.get_n_items () - 1) { |
| 207 | + current_audio = null; |
| 208 | + return; |
| 209 | + } |
| 210 | + |
| 211 | + current_audio = (AudioObject) queue_liststore.get_item (position + 1); |
| 212 | + |
201 | 213 | break; |
202 | 214 |
|
203 | 215 | case "all": |
204 | | - if (!from_queue) { |
205 | | - ask_has_next (true); |
206 | | - return; |
207 | | - } else { |
| 216 | + if (position == queue_liststore.get_n_items () - 1) { |
208 | 217 | current_audio = (AudioObject) queue_liststore.get_item (0); |
209 | 218 | if (position == 0) { |
210 | 219 | seek_to_progress (0); |
211 | 220 | } |
212 | | - return; |
| 221 | + } else { |
| 222 | + current_audio = (AudioObject) queue_liststore.get_item (position + 1); |
213 | 223 | } |
214 | 224 |
|
| 225 | + break; |
| 226 | + |
215 | 227 | case "one": |
216 | 228 | seek_to_progress (0); |
217 | | - return; |
| 229 | + break; |
218 | 230 | } |
219 | 231 | } |
220 | | - |
221 | | - ask_has_next (false); |
222 | 232 | } |
223 | 233 |
|
224 | 234 | public void previous () { |
225 | 235 | direction = Direction.PREVIOUS; |
226 | 236 | uint position = -1; |
| 237 | + queue_liststore.find (current_audio, out position); |
227 | 238 |
|
228 | | - if (queue_liststore.find (current_audio, out position)) { |
229 | | - if (position == 0) { |
230 | | - uint n_items = queue_liststore.get_n_items (); |
231 | | - if (n_items == 1) { |
232 | | - seek_to_progress (0); |
233 | | - } else { |
234 | | - current_audio = (AudioObject) queue_liststore.get_item (n_items - 1); |
235 | | - } |
236 | | - |
237 | | - return; |
238 | | - } |
239 | | - |
| 239 | + if (position != -1 && position != 0) { |
240 | 240 | current_audio = (AudioObject) queue_liststore.get_item (position - 1); |
241 | | - return; |
242 | 241 | } |
243 | 242 |
|
244 | | - ask_has_previous (); |
| 243 | + if (position == 0) { |
| 244 | + uint n_items = queue_liststore.get_n_items (); |
| 245 | + if (n_items == 1) { |
| 246 | + seek_to_progress (0); |
| 247 | + } else { |
| 248 | + current_audio = (AudioObject) queue_liststore.get_item (n_items - 1); |
| 249 | + } |
| 250 | + } |
245 | 251 | } |
246 | 252 |
|
247 | 253 | public void shuffle () { |
|
0 commit comments