Fix jump-to-time from audio captions.

This commit is contained in:
John Preston 2020-02-06 13:19:33 +04:00
parent 76ff9a562e
commit 6cf9157fb5
2 changed files with 8 additions and 6 deletions

View file

@ -189,14 +189,16 @@ void Instance::setCurrent(const AudioMsgId &audioId) {
}
}
void Instance::clearStreamed(not_null<Data*> data) {
void Instance::clearStreamed(not_null<Data*> data, bool savePosition) {
if (!data->streamed || data->streamed->clearing) {
return;
}
data->streamed->clearing = true;
SaveLastPlaybackPosition(
data->current.audio(),
data->streamed->instance.player().prepareLegacyState());
if (savePosition) {
SaveLastPlaybackPosition(
data->current.audio(),
data->streamed->instance.player().prepareLegacyState());
}
data->streamed->instance.stop();
data->isPlaying = false;
requestRoundVideoResize();
@ -414,7 +416,7 @@ void Instance::playStreamed(
const auto data = getData(audioId.type());
Assert(data != nullptr);
clearStreamed(data);
clearStreamed(data, data->current.audio() != audioId.audio());
data->streamed = std::make_unique<Streamed>(
audioId,
std::move(shared));

View file

@ -225,7 +225,7 @@ private:
not_null<Data*> data,
Streaming::Error &&error);
void clearStreamed(not_null<Data *> data);
void clearStreamed(not_null<Data*> data, bool savePosition = true);
void emitUpdate(AudioMsgId::Type type);
template <typename CheckCallback>
void emitUpdate(AudioMsgId::Type type, CheckCallback check);