2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2021-01-01 19:54:25 +01:00
|
|
|
* Copyright 2003-2021 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
#include "Playlist.hxx"
|
2016-03-10 20:10:14 +01:00
|
|
|
#include "Listener.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "PlaylistError.hxx"
|
2015-08-15 15:55:46 +02:00
|
|
|
#include "player/Control.hxx"
|
2018-08-02 13:45:43 +02:00
|
|
|
#include "song/DetachedSong.hxx"
|
2018-02-05 17:13:00 +01:00
|
|
|
#include "SingleMode.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "Log.hxx"
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2020-03-12 23:20:59 +01:00
|
|
|
#include <cassert>
|
2004-06-05 03:14:37 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::TagModified(DetachedSong &&song) noexcept
|
2009-01-20 22:49:19 +01:00
|
|
|
{
|
2014-01-07 21:39:47 +01:00
|
|
|
if (!playing)
|
2009-01-20 22:49:19 +01:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
assert(current >= 0);
|
2009-01-23 00:09:26 +01:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
DetachedSong ¤t_song = queue.GetOrder(current);
|
|
|
|
if (song.IsSame(current_song))
|
2016-02-23 21:01:55 +01:00
|
|
|
current_song.MoveTagItemsFrom(std::move(song));
|
2013-10-21 23:22:16 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.ModifyAtOrder(current);
|
2016-03-10 20:03:01 +01:00
|
|
|
OnModified();
|
2009-01-20 22:49:19 +01:00
|
|
|
}
|
|
|
|
|
2018-01-29 12:02:14 +01:00
|
|
|
void
|
2021-05-18 18:45:07 +02:00
|
|
|
playlist::TagModified(const char *real_uri, const Tag &tag) noexcept
|
2018-01-29 12:02:14 +01:00
|
|
|
{
|
|
|
|
bool modified = false;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < queue.length; ++i) {
|
|
|
|
auto &song = *queue.items[i].song;
|
2021-05-18 18:45:07 +02:00
|
|
|
if (song.IsRealURI(real_uri)) {
|
2018-01-29 12:02:14 +01:00
|
|
|
song.SetTag(tag);
|
|
|
|
queue.ModifyAtPosition(i);
|
|
|
|
modified = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (modified)
|
|
|
|
OnModified();
|
|
|
|
}
|
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
inline void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::QueueSongOrder(PlayerControl &pc, unsigned order) noexcept
|
2014-11-26 08:34:51 +01:00
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2014-11-26 08:34:51 +01:00
|
|
|
assert(queue.IsValidOrder(order));
|
2009-01-04 19:09:34 +01:00
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
queued = order;
|
2009-01-04 19:09:34 +01:00
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
const DetachedSong &song = queue.GetOrder(order);
|
2012-08-09 22:19:39 +02:00
|
|
|
|
2021-06-25 17:26:41 +02:00
|
|
|
FmtDebug(playlist_domain, "queue song {}:\"{}\"",
|
|
|
|
queued, song.GetURI());
|
2009-01-23 00:06:54 +01:00
|
|
|
|
2017-11-26 11:46:14 +01:00
|
|
|
pc.LockEnqueueSong(std::make_unique<DetachedSong>(song));
|
2009-01-23 00:06:54 +01:00
|
|
|
}
|
2009-01-04 19:09:34 +01:00
|
|
|
|
2014-11-26 08:49:19 +01:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::SongStarted() noexcept
|
2014-11-26 08:49:19 +01:00
|
|
|
{
|
|
|
|
assert(current >= 0);
|
2014-11-26 08:54:16 +01:00
|
|
|
|
|
|
|
/* reset a song's "priority" when playback starts */
|
|
|
|
if (queue.SetPriority(queue.OrderToPosition(current), 0, -1, false))
|
|
|
|
OnModified();
|
2014-11-26 08:49:19 +01:00
|
|
|
}
|
|
|
|
|
2014-11-25 19:21:22 +01:00
|
|
|
inline void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::QueuedSongStarted(PlayerControl &pc) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2018-09-23 17:15:08 +02:00
|
|
|
assert(!pc.LockGetSyncInfo().has_next_song);
|
2014-11-25 19:21:22 +01:00
|
|
|
assert(queued >= -1);
|
2014-11-26 08:25:48 +01:00
|
|
|
assert(current >= 0);
|
2009-01-23 07:33:15 +01:00
|
|
|
|
2010-06-19 13:33:32 +02:00
|
|
|
/* queued song has started: copy queued to current,
|
|
|
|
and notify the clients */
|
2010-06-01 09:59:46 +02:00
|
|
|
|
2014-11-25 19:21:22 +01:00
|
|
|
const int old_current = current;
|
|
|
|
current = queued;
|
|
|
|
queued = -1;
|
2010-05-31 23:32:11 +02:00
|
|
|
|
2014-11-25 19:21:22 +01:00
|
|
|
if (queue.consume)
|
|
|
|
DeleteOrder(pc, old_current);
|
2010-06-19 13:33:32 +02:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueSongStarted();
|
2014-11-26 08:49:19 +01:00
|
|
|
|
|
|
|
SongStarted();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong *
|
2017-05-08 14:44:49 +02:00
|
|
|
playlist::GetQueuedSong() const noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
return playing && queued >= 0
|
2013-10-19 18:48:38 +02:00
|
|
|
? &queue.GetOrder(queued)
|
2013-01-07 10:55:05 +01:00
|
|
|
: nullptr;
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
|
|
|
|
2009-02-04 20:31:22 +01:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::UpdateQueuedSong(PlayerControl &pc,
|
|
|
|
const DetachedSong *prev) noexcept
|
2009-02-04 18:52:37 +01:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (!playing)
|
2009-02-04 18:52:37 +01:00
|
|
|
return;
|
|
|
|
|
2014-07-11 20:01:53 +02:00
|
|
|
if (prev == nullptr && bulk_edit)
|
|
|
|
/* postponed until CommitBulk() to avoid always
|
|
|
|
queueing the first song that is being added (in
|
|
|
|
random mode) */
|
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
assert(!queue.IsEmpty());
|
2013-10-02 08:13:28 +02:00
|
|
|
assert((queued < 0) == (prev == nullptr));
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
const int next_order = current >= 0
|
|
|
|
? queue.GetNextOrder(current)
|
2009-02-04 18:52:37 +01:00
|
|
|
: 0;
|
|
|
|
|
2018-02-05 17:13:00 +01:00
|
|
|
if (next_order == 0 && queue.random && queue.single == SingleMode::OFF) {
|
2009-02-04 18:52:37 +01:00
|
|
|
/* shuffle the song order again, so we get a different
|
|
|
|
order each time the playlist is played
|
|
|
|
completely */
|
2013-01-07 10:55:05 +01:00
|
|
|
const unsigned current_position =
|
|
|
|
queue.OrderToPosition(current);
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.ShuffleOrder();
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
/* make sure that the current still points to
|
2009-02-04 18:52:37 +01:00
|
|
|
the current song, after the song order has been
|
|
|
|
shuffled */
|
2013-01-07 10:55:05 +01:00
|
|
|
current = queue.PositionToOrder(current_position);
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong *const next_song = next_order >= 0
|
2013-10-19 18:48:38 +02:00
|
|
|
? &queue.GetOrder(next_order)
|
2013-01-07 10:55:05 +01:00
|
|
|
: nullptr;
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2013-10-02 08:13:28 +02:00
|
|
|
if (prev != nullptr && next_song != prev) {
|
2009-02-04 18:52:37 +01:00
|
|
|
/* clear the currently queued song */
|
2015-11-11 16:50:57 +01:00
|
|
|
pc.LockCancel();
|
2013-01-07 10:55:05 +01:00
|
|
|
queued = -1;
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:52:37 +01:00
|
|
|
if (next_order >= 0) {
|
|
|
|
if (next_song != prev)
|
2014-11-26 08:34:51 +01:00
|
|
|
QueueSongOrder(pc, next_order);
|
2009-02-04 18:52:37 +01:00
|
|
|
else
|
2013-01-07 10:55:05 +01:00
|
|
|
queued = next_order;
|
2009-02-04 18:52:37 +01:00
|
|
|
}
|
2008-04-12 06:11:56 +02:00
|
|
|
}
|
|
|
|
|
2016-09-08 10:29:49 +02:00
|
|
|
void
|
|
|
|
playlist::PlayOrder(PlayerControl &pc, unsigned order)
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
playing = true;
|
|
|
|
queued = -1;
|
2007-12-28 03:56:25 +01:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong &song = queue.GetOrder(order);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2021-06-25 17:26:41 +02:00
|
|
|
FmtDebug(playlist_domain, "play {}:\"{}\"", order, song.GetURI());
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
current = order;
|
2014-11-26 08:49:19 +01:00
|
|
|
|
2017-11-26 11:46:14 +01:00
|
|
|
pc.Play(std::make_unique<DetachedSong>(song));
|
2015-11-11 19:57:37 +01:00
|
|
|
|
2014-11-26 08:49:19 +01:00
|
|
|
SongStarted();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::SyncWithPlayer(PlayerControl &pc) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (!playing)
|
2009-01-23 07:33:15 +01:00
|
|
|
/* this event has reached us out of sync: we aren't
|
|
|
|
playing anymore; ignore the event */
|
2006-07-20 18:02:40 +02:00
|
|
|
return;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2018-09-23 17:15:08 +02:00
|
|
|
const auto i = pc.LockGetSyncInfo();
|
2010-06-19 13:15:42 +02:00
|
|
|
|
2018-09-23 17:15:08 +02:00
|
|
|
if (i.state == PlayerState::STOP)
|
2009-01-23 07:33:15 +01:00
|
|
|
/* the player thread has stopped: check if playback
|
|
|
|
should be restarted with the next song. That can
|
|
|
|
happen if the playlist isn't filling the queue fast
|
|
|
|
enough */
|
2014-11-26 08:34:51 +01:00
|
|
|
ResumePlayback(pc);
|
2008-08-26 08:27:18 +02:00
|
|
|
else {
|
2009-01-23 07:33:15 +01:00
|
|
|
/* check if the player thread has already started
|
|
|
|
playing the queued song */
|
2018-09-23 17:15:08 +02:00
|
|
|
if (!i.has_next_song && queued != -1)
|
2014-11-25 19:21:22 +01:00
|
|
|
QueuedSongStarted(pc);
|
2009-01-23 07:33:15 +01:00
|
|
|
|
|
|
|
/* make sure the queued song is always set (if
|
|
|
|
possible) */
|
2018-09-23 17:15:08 +02:00
|
|
|
if (!pc.LockGetSyncInfo().has_next_song && queued < 0)
|
2013-01-07 10:55:05 +01:00
|
|
|
UpdateQueuedSong(pc, nullptr);
|
2008-08-26 08:27:18 +02:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
inline void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::ResumePlayback(PlayerControl &pc) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2014-11-26 08:34:51 +01:00
|
|
|
assert(playing);
|
2013-10-19 18:48:38 +02:00
|
|
|
assert(pc.GetState() == PlayerState::STOP);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-10-19 18:48:38 +02:00
|
|
|
const auto error = pc.GetErrorType();
|
2013-09-27 22:07:20 +02:00
|
|
|
if (error == PlayerError::NONE)
|
2014-11-26 08:34:51 +01:00
|
|
|
error_count = 0;
|
2009-01-23 06:40:52 +01:00
|
|
|
else
|
2014-11-26 08:34:51 +01:00
|
|
|
++error_count;
|
2009-01-23 06:40:52 +01:00
|
|
|
|
2014-11-26 08:34:51 +01:00
|
|
|
if ((stop_on_error && error != PlayerError::NONE) ||
|
2013-09-27 22:07:20 +02:00
|
|
|
error == PlayerError::OUTPUT ||
|
2014-11-26 08:34:51 +01:00
|
|
|
error_count >= queue.GetLength())
|
2009-01-23 07:33:15 +01:00
|
|
|
/* too many errors, or critical error: stop
|
|
|
|
playback */
|
2014-11-26 08:34:51 +01:00
|
|
|
Stop(pc);
|
2009-01-23 06:40:52 +01:00
|
|
|
else
|
2009-01-23 07:33:15 +01:00
|
|
|
/* continue playback at the next song */
|
2016-09-08 10:29:49 +02:00
|
|
|
try {
|
|
|
|
PlayNext(pc);
|
|
|
|
} catch (...) {
|
|
|
|
/* TODO: log error? */
|
|
|
|
}
|
2009-03-30 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::SetRepeat(PlayerControl &pc, bool status) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.repeat)
|
2009-01-23 00:07:20 +01:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.repeat = status;
|
2012-08-25 08:44:31 +02:00
|
|
|
|
2018-02-05 17:13:00 +01:00
|
|
|
pc.LockSetBorderPause(queue.single != SingleMode::OFF && !queue.repeat);
|
2008-10-14 22:38:14 +02:00
|
|
|
|
2009-02-04 18:52:37 +01:00
|
|
|
/* if the last song is currently being played, the "next song"
|
|
|
|
might change when repeat mode is toggled */
|
2013-01-07 10:55:05 +01:00
|
|
|
UpdateQueuedSong(pc, GetQueuedSong());
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
static void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist_order(playlist &playlist) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-10-19 18:48:38 +02:00
|
|
|
if (playlist.current >= 0)
|
2009-01-23 07:33:15 +01:00
|
|
|
/* update playlist.current, order==position now */
|
2013-10-19 18:48:38 +02:00
|
|
|
playlist.current = playlist.queue.OrderToPosition(playlist.current);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-10-19 18:48:38 +02:00
|
|
|
playlist.queue.RestoreOrder();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::SetSingle(PlayerControl &pc, SingleMode status) noexcept
|
2009-03-27 14:42:55 +01:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.single)
|
2009-03-27 15:28:49 +01:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.single = status;
|
2012-08-25 08:44:31 +02:00
|
|
|
|
2018-02-05 17:13:00 +01:00
|
|
|
|
|
|
|
pc.LockSetBorderPause(queue.single != SingleMode::OFF && !queue.repeat);
|
2009-03-27 14:42:55 +01:00
|
|
|
|
|
|
|
/* if the last song is currently being played, the "next song"
|
2009-03-27 15:28:49 +01:00
|
|
|
might change when single mode is toggled */
|
2013-01-07 10:55:05 +01:00
|
|
|
UpdateQueuedSong(pc, GetQueuedSong());
|
2009-03-27 14:42:55 +01:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2009-03-27 14:42:55 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::SetConsume(bool status) noexcept
|
2009-03-30 00:01:02 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.consume)
|
2009-03-30 00:01:02 +02:00
|
|
|
return;
|
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.consume = status;
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2009-03-30 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::SetRandom(PlayerControl &pc, bool status) noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (status == queue.random)
|
2008-10-08 11:05:02 +02:00
|
|
|
return;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2014-01-07 21:39:47 +01:00
|
|
|
const DetachedSong *const queued_song = GetQueuedSong();
|
2009-01-23 00:07:10 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.random = status;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
if (queue.random) {
|
|
|
|
/* shuffle the queue order, but preserve current */
|
2009-01-23 07:33:15 +01:00
|
|
|
|
2014-07-11 19:41:39 +02:00
|
|
|
const int current_position = playing
|
|
|
|
? GetCurrentPosition()
|
|
|
|
: -1;
|
2009-01-23 00:08:40 +01:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.ShuffleOrder();
|
2009-01-23 00:08:40 +01:00
|
|
|
|
|
|
|
if (current_position >= 0) {
|
2009-01-23 07:33:15 +01:00
|
|
|
/* make sure the current song is the first in
|
|
|
|
the order list, so the whole rest of the
|
|
|
|
playlist is played after that */
|
2009-01-23 00:08:40 +01:00
|
|
|
unsigned current_order =
|
2013-01-07 10:55:05 +01:00
|
|
|
queue.PositionToOrder(current_position);
|
2017-10-18 08:46:31 +02:00
|
|
|
current = queue.MoveOrder(current_order, 0);
|
2009-02-11 18:02:50 +01:00
|
|
|
} else
|
2013-01-07 10:55:05 +01:00
|
|
|
current = -1;
|
2008-10-08 11:05:02 +02:00
|
|
|
} else
|
2013-10-19 18:48:38 +02:00
|
|
|
playlist_order(*this);
|
2008-10-14 22:38:14 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
UpdateQueuedSong(pc, queued_song);
|
2009-02-04 18:52:37 +01:00
|
|
|
|
2016-03-10 20:10:14 +01:00
|
|
|
listener.OnQueueOptionsChanged();
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
int
|
2017-05-08 14:44:49 +02:00
|
|
|
playlist::GetCurrentPosition() const noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
return current >= 0
|
|
|
|
? queue.OrderToPosition(current)
|
|
|
|
: -1;
|
2006-03-26 15:46:05 +02:00
|
|
|
}
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
int
|
2017-05-08 14:44:49 +02:00
|
|
|
playlist::GetNextPosition() const noexcept
|
2006-07-20 18:02:40 +02:00
|
|
|
{
|
2013-01-07 10:55:05 +01:00
|
|
|
if (current < 0)
|
|
|
|
return -1;
|
2006-03-26 15:46:05 +02:00
|
|
|
|
2018-02-05 17:13:00 +01:00
|
|
|
if (queue.single != SingleMode::OFF && queue.repeat)
|
2013-01-07 10:55:05 +01:00
|
|
|
return queue.OrderToPosition(current);
|
|
|
|
else if (queue.IsValidOrder(current + 1))
|
|
|
|
return queue.OrderToPosition(current + 1);
|
|
|
|
else if (queue.repeat)
|
|
|
|
return queue.OrderToPosition(0);
|
2006-03-26 15:46:05 +02:00
|
|
|
|
2013-01-07 10:55:05 +01:00
|
|
|
return -1;
|
2006-03-26 15:46:05 +02:00
|
|
|
}
|
2018-02-05 17:13:00 +01:00
|
|
|
|
|
|
|
void
|
2019-05-31 13:56:09 +02:00
|
|
|
playlist::BorderPause(PlayerControl &pc) noexcept
|
2018-02-05 17:13:00 +01:00
|
|
|
{
|
|
|
|
if (queue.single == SingleMode::ONE_SHOT) {
|
|
|
|
queue.single = SingleMode::OFF;
|
|
|
|
pc.LockSetBorderPause(false);
|
|
|
|
|
|
|
|
listener.OnQueueOptionsChanged();
|
|
|
|
}
|
|
|
|
}
|