2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-01 07:05:13 +00:00

Use streaming player speed in 2x playback.

This commit is contained in:
John Preston
2019-03-26 16:50:00 +04:00
parent e87084715d
commit bf182697b9
6 changed files with 23 additions and 96 deletions

View File

@@ -31,6 +31,8 @@ namespace {
Instance *SingleInstance = nullptr;
constexpr auto kVoicePlaybackSpeedMultiplier = 1.7;
// Preload X message ids before and after current.
constexpr auto kIdsLimit = 32;
@@ -408,6 +410,11 @@ Streaming::PlaybackOptions Instance::streamingOptions(
result.mode = (document && document->isVideoMessage())
? Streaming::Mode::Both
: Streaming::Mode::Audio;
result.speed = (document
&& (document->isVoiceMessage() || document->isVideoMessage())
&& Global::VoiceMsgPlaybackDoubled())
? kVoicePlaybackSpeedMultiplier
: 1.;
result.audioId = audioId;
result.position = position;
return result;
@@ -543,6 +550,16 @@ void Instance::cancelSeeking(AudioMsgId::Type type) {
emitUpdate(type);
}
void Instance::updateVoicePlaybackSpeed() {
if (const auto data = getData(AudioMsgId::Type::Voice)) {
if (const auto streamed = data->streamed.get()) {
streamed->player.setSpeed(Global::VoiceMsgPlaybackDoubled()
? kVoicePlaybackSpeedMultiplier
: 1.);
}
}
}
void Instance::documentLoadProgress(DocumentData *document) {
const auto type = document->isAudioFile()
? AudioMsgId::Type::Song