Added disable-autoplay-next option.

This commit is contained in:
23rd 2022-03-05 12:40:49 +03:00
parent c6cdf0a4c4
commit f469cab7b0
3 changed files with 16 additions and 0 deletions

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_changes.h" #include "data/data_changes.h"
#include "data/data_streaming.h" #include "data/data_streaming.h"
#include "data/data_file_click_handler.h" #include "data/data_file_click_handler.h"
#include "base/options.h"
#include "base/random.h" #include "base/random.h"
#include "base/power_save_blocker.h" #include "base/power_save_blocker.h"
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
@ -55,8 +56,17 @@ auto VoicePlaybackSpeed() {
return std::clamp(Core::App().settings().voicePlaybackSpeed(), 0.6, 1.7); return std::clamp(Core::App().settings().voicePlaybackSpeed(), 0.6, 1.7);
} }
base::options::toggle OptionDisableAutoplayNext({
.id = kOptionDisableAutoplayNext,
.name = "Disable auto-play of the next track",
.description = "Disable auto-play of the next "
"Audio file / Voice Message / Video message.",
});
} // namespace } // namespace
const char kOptionDisableAutoplayNext[] = "disable-autoplay-next";
struct Instance::Streamed { struct Instance::Streamed {
Streamed( Streamed(
AudioMsgId id, AudioMsgId id,
@ -1212,6 +1222,8 @@ void Instance::emitUpdate(AudioMsgId::Type type, CheckCallback check) {
if (data->isPlaying && state.state == State::StoppedAtEnd) { if (data->isPlaying && state.state == State::StoppedAtEnd) {
if (repeat(data) == RepeatMode::One) { if (repeat(data) == RepeatMode::One) {
play(data->current); play(data->current);
} else if (OptionDisableAutoplayNext.value()) {
finished = true;
} else if (!moveInPlaylist(data, 1, true)) { } else if (!moveInPlaylist(data, 1, true)) {
finished = true; finished = true;
} }

View File

@ -42,6 +42,8 @@ class PowerSaveBlocker;
namespace Media { namespace Media {
namespace Player { namespace Player {
extern const char kOptionDisableAutoplayNext[];
enum class RepeatMode { enum class RepeatMode {
None, None,
One, One,

View File

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h" #include "core/application.h"
#include "chat_helpers/tabbed_panel.h" #include "chat_helpers/tabbed_panel.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "media/player/media_player_instance.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_controller.h" #include "window/window_controller.h"
@ -131,6 +132,7 @@ void SetupExperimental(
addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick); addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick);
addToggle(Window::kOptionViewProfileInChatsListContextMenu); addToggle(Window::kOptionViewProfileInChatsListContextMenu);
addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL); addToggle(Ui::GL::kOptionAllowLinuxNvidiaOpenGL);
addToggle(Media::Player::kOptionDisableAutoplayNext);
} }
} // namespace } // namespace