2016-09-23 16:04:26 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-09-23 16:04:26 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-09-23 16:04:26 +00:00
|
|
|
*/
|
|
|
|
#include "media/player/media_player_instance.h"
|
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_document.h"
|
2018-03-09 21:32:52 +00:00
|
|
|
#include "data/data_session.h"
|
2019-12-28 14:56:06 +00:00
|
|
|
#include "data/data_streaming.h"
|
2019-02-13 12:36:59 +00:00
|
|
|
#include "media/audio/media_audio.h"
|
|
|
|
#include "media/audio/media_audio_capture.h"
|
2019-12-11 12:09:21 +00:00
|
|
|
#include "media/streaming/media_streaming_instance.h"
|
|
|
|
#include "media/streaming/media_streaming_player.h"
|
2019-03-26 08:54:51 +00:00
|
|
|
#include "media/view/media_view_playback_progress.h"
|
2017-05-12 17:44:18 +00:00
|
|
|
#include "calls/calls_instance.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
|
|
|
#include "history/history_item.h"
|
2018-01-14 16:02:25 +00:00
|
|
|
#include "data/data_media_types.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_file_origin.h"
|
2019-06-06 10:21:40 +00:00
|
|
|
#include "window/window_session_controller.h"
|
2018-11-16 12:15:14 +00:00
|
|
|
#include "core/shortcuts.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/application.h"
|
2019-06-06 09:37:12 +00:00
|
|
|
#include "main/main_account.h" // Account::sessionValue.
|
2018-01-21 14:49:42 +00:00
|
|
|
#include "mainwindow.h"
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "facades.h"
|
2016-09-23 16:04:26 +00:00
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
namespace Player {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
Instance *SingleInstance = nullptr;
|
|
|
|
|
2019-03-26 12:50:00 +00:00
|
|
|
constexpr auto kVoicePlaybackSpeedMultiplier = 1.7;
|
|
|
|
|
2017-12-09 10:02:51 +00:00
|
|
|
// Preload X message ids before and after current.
|
|
|
|
constexpr auto kIdsLimit = 32;
|
|
|
|
|
|
|
|
// Preload next messages if we went further from current than that.
|
|
|
|
constexpr auto kIdsPreloadAfter = 28;
|
|
|
|
|
2019-12-31 07:30:06 +00:00
|
|
|
constexpr auto kMinLengthForSavePosition = 20 * TimeId(60); // 20 minutes.
|
|
|
|
|
2016-09-23 16:04:26 +00:00
|
|
|
} // namespace
|
|
|
|
|
2019-12-31 07:30:06 +00:00
|
|
|
struct Instance::Streamed {
|
|
|
|
Streamed(
|
|
|
|
AudioMsgId id,
|
|
|
|
std::shared_ptr<Streaming::Document> document);
|
|
|
|
|
|
|
|
AudioMsgId id;
|
|
|
|
Streaming::Instance instance;
|
|
|
|
View::PlaybackProgress progress;
|
|
|
|
bool clearing = false;
|
|
|
|
rpl::lifetime lifetime;
|
|
|
|
};
|
|
|
|
|
2019-02-01 07:09:55 +00:00
|
|
|
void start(not_null<Audio::Instance*> instance) {
|
|
|
|
Audio::Start(instance);
|
2017-05-03 11:36:39 +00:00
|
|
|
Capture::Start();
|
2016-09-23 16:04:26 +00:00
|
|
|
|
2017-01-19 08:24:43 +00:00
|
|
|
SingleInstance = new Instance();
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2019-02-01 07:09:55 +00:00
|
|
|
void finish(not_null<Audio::Instance*> instance) {
|
2016-10-08 09:10:33 +00:00
|
|
|
delete base::take(SingleInstance);
|
2016-09-23 16:04:26 +00:00
|
|
|
|
2017-05-03 11:36:39 +00:00
|
|
|
Capture::Finish();
|
2019-02-01 07:09:55 +00:00
|
|
|
Audio::Finish(instance);
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2019-12-31 07:30:06 +00:00
|
|
|
void SaveLastPlaybackPosition(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
const TrackState &state) {
|
|
|
|
const auto time = (state.position == kTimeUnknown
|
|
|
|
|| state.length == kTimeUnknown
|
|
|
|
|| state.state == State::PausedAtEnd
|
|
|
|
|| IsStopped(state.state))
|
|
|
|
? TimeId(0)
|
|
|
|
: (state.length >= kMinLengthForSavePosition * state.frequency)
|
|
|
|
? (state.position / state.frequency) * crl::time(1000)
|
|
|
|
: TimeId(0);
|
|
|
|
auto &session = document->session();
|
|
|
|
if (session.settings().mediaLastPlaybackPosition(document->id) != time) {
|
|
|
|
session.settings().setMediaLastPlaybackPosition(document->id, time);
|
|
|
|
session.saveSettingsDelayed();
|
|
|
|
}
|
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
|
|
|
|
Instance::Streamed::Streamed(
|
|
|
|
AudioMsgId id,
|
2019-12-11 10:15:48 +00:00
|
|
|
std::shared_ptr<Streaming::Document> document)
|
2019-02-28 21:03:25 +00:00
|
|
|
: id(id)
|
2019-12-11 12:09:21 +00:00
|
|
|
, instance(std::move(document), nullptr) {
|
2019-02-28 21:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Instance::Data::Data(AudioMsgId::Type type, SharedMediaType overview)
|
|
|
|
: type(type)
|
|
|
|
, overview(overview) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Instance::Data::Data(Data &&other) = default;
|
|
|
|
Instance::Data &Instance::Data::operator=(Data &&other) = default;
|
|
|
|
Instance::Data::~Data() = default;
|
|
|
|
|
2017-05-19 18:11:33 +00:00
|
|
|
Instance::Instance()
|
2017-12-08 18:27:28 +00:00
|
|
|
: _songData(AudioMsgId::Type::Song, SharedMediaType::MusicFile)
|
|
|
|
, _voiceData(AudioMsgId::Type::Voice, SharedMediaType::RoundVoiceFile) {
|
2017-01-19 08:24:43 +00:00
|
|
|
subscribe(Media::Player::Updated(), [this](const AudioMsgId &audioId) {
|
2017-02-10 22:37:37 +00:00
|
|
|
handleSongUpdate(audioId);
|
2016-09-23 16:04:26 +00:00
|
|
|
});
|
2017-05-12 17:44:18 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
// While we have one Media::Player::Instance for all sessions we have to do this.
|
2020-06-10 14:52:44 +00:00
|
|
|
Core::App().activeAccount().sessionValue( // #TODO multi activeSessionValue
|
2019-07-24 11:45:24 +00:00
|
|
|
) | rpl::start_with_next([=](Main::Session *session) {
|
2019-06-06 09:37:12 +00:00
|
|
|
if (session) {
|
|
|
|
subscribe(session->calls().currentCallChanged(), [=](Calls::Call *call) {
|
2017-05-12 17:44:18 +00:00
|
|
|
if (call) {
|
2018-10-31 06:51:19 +00:00
|
|
|
pauseOnCall(AudioMsgId::Type::Voice);
|
|
|
|
pauseOnCall(AudioMsgId::Type::Song);
|
|
|
|
} else {
|
|
|
|
resumeOnCall(AudioMsgId::Type::Voice);
|
|
|
|
resumeOnCall(AudioMsgId::Type::Song);
|
2017-05-12 17:44:18 +00:00
|
|
|
}
|
|
|
|
});
|
2019-06-06 09:37:12 +00:00
|
|
|
} else {
|
|
|
|
const auto reset = [&](AudioMsgId::Type type) {
|
|
|
|
const auto data = getData(type);
|
|
|
|
*data = Data(type, data->overview);
|
|
|
|
};
|
|
|
|
reset(AudioMsgId::Type::Voice);
|
|
|
|
reset(AudioMsgId::Type::Song);
|
2017-05-12 17:44:18 +00:00
|
|
|
}
|
2019-06-06 09:37:12 +00:00
|
|
|
}, _lifetime);
|
2018-11-16 12:15:14 +00:00
|
|
|
|
|
|
|
setupShortcuts();
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
Instance::~Instance() = default;
|
|
|
|
|
2017-05-19 18:11:33 +00:00
|
|
|
AudioMsgId::Type Instance::getActiveType() const {
|
2019-03-26 08:54:51 +00:00
|
|
|
if (const auto data = getData(AudioMsgId::Type::Voice)) {
|
|
|
|
if (data->current) {
|
|
|
|
const auto state = getState(data->type);
|
|
|
|
if (!IsStoppedOrStopping(state.state)) {
|
|
|
|
return data->type;
|
|
|
|
}
|
2017-05-19 18:11:33 +00:00
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
2017-05-19 18:11:33 +00:00
|
|
|
return AudioMsgId::Type::Song;
|
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
|
|
|
|
void Instance::handleSongUpdate(const AudioMsgId &audioId) {
|
2019-03-26 08:54:51 +00:00
|
|
|
emitUpdate(audioId.type(), [&](const AudioMsgId &playing) {
|
2016-09-23 16:04:26 +00:00
|
|
|
return (audioId == playing);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::setCurrent(const AudioMsgId &audioId) {
|
2019-02-28 21:03:25 +00:00
|
|
|
if (const auto data = getData(audioId.type())) {
|
|
|
|
if (data->current == audioId) {
|
|
|
|
return;
|
|
|
|
}
|
2019-03-05 13:56:27 +00:00
|
|
|
const auto changed = [&](const AudioMsgId & check) {
|
|
|
|
return (check.audio() != audioId.audio())
|
|
|
|
|| (check.contextId() != audioId.contextId());
|
|
|
|
};
|
2019-03-11 14:35:11 +00:00
|
|
|
if (changed(data->current)
|
|
|
|
&& data->streamed
|
|
|
|
&& changed(data->streamed->id)) {
|
2019-03-05 13:56:27 +00:00
|
|
|
clearStreamed(data);
|
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
data->current = audioId;
|
|
|
|
data->isPlaying = false;
|
|
|
|
|
2020-06-08 09:06:50 +00:00
|
|
|
const auto item = (audioId.audio() && audioId.contextId())
|
|
|
|
? audioId.audio()->owner().message(audioId.contextId())
|
|
|
|
: nullptr;
|
2019-02-28 21:03:25 +00:00
|
|
|
if (item) {
|
|
|
|
data->history = item->history()->migrateToOrMe();
|
|
|
|
data->migrated = data->history->migrateFrom();
|
|
|
|
} else {
|
|
|
|
data->history = nullptr;
|
|
|
|
data->migrated = nullptr;
|
|
|
|
}
|
|
|
|
_trackChangedNotifier.notify(data->type, true);
|
|
|
|
refreshPlaylist(data);
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 09:19:33 +00:00
|
|
|
void Instance::clearStreamed(not_null<Data*> data, bool savePosition) {
|
2019-06-01 09:30:38 +00:00
|
|
|
if (!data->streamed || data->streamed->clearing) {
|
2019-03-05 13:56:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-06-01 09:30:38 +00:00
|
|
|
data->streamed->clearing = true;
|
2020-02-06 09:19:33 +00:00
|
|
|
if (savePosition) {
|
|
|
|
SaveLastPlaybackPosition(
|
|
|
|
data->current.audio(),
|
|
|
|
data->streamed->instance.player().prepareLegacyState());
|
|
|
|
}
|
2019-12-11 12:09:21 +00:00
|
|
|
data->streamed->instance.stop();
|
2019-03-05 13:56:27 +00:00
|
|
|
data->isPlaying = false;
|
2019-03-26 08:54:51 +00:00
|
|
|
requestRoundVideoResize();
|
2019-03-05 13:56:27 +00:00
|
|
|
emitUpdate(data->type);
|
|
|
|
data->streamed = nullptr;
|
2019-06-06 10:21:40 +00:00
|
|
|
App::wnd()->sessionController()->disableGifPauseReason(
|
2019-03-26 08:54:51 +00:00
|
|
|
Window::GifPauseReason::RoundPlaying);
|
2019-03-05 13:56:27 +00:00
|
|
|
}
|
|
|
|
|
2017-12-09 10:02:51 +00:00
|
|
|
void Instance::refreshPlaylist(not_null<Data*> data) {
|
|
|
|
if (!validPlaylist(data)) {
|
|
|
|
validatePlaylist(data);
|
|
|
|
}
|
|
|
|
playlistUpdated(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::playlistUpdated(not_null<Data*> data) {
|
|
|
|
if (data->playlistSlice) {
|
|
|
|
const auto fullId = data->current.contextId();
|
|
|
|
data->playlistIndex = data->playlistSlice->indexOf(fullId);
|
|
|
|
} else {
|
2018-09-21 16:28:46 +00:00
|
|
|
data->playlistIndex = std::nullopt;
|
2017-12-09 10:02:51 +00:00
|
|
|
}
|
|
|
|
data->playlistChanges.fire({});
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Instance::validPlaylist(not_null<Data*> data) {
|
|
|
|
if (const auto key = playlistKey(data)) {
|
|
|
|
if (!data->playlistSlice) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
using Key = SliceKey;
|
|
|
|
const auto inSameDomain = [](const Key &a, const Key &b) {
|
|
|
|
return (a.peerId == b.peerId)
|
|
|
|
&& (a.migratedPeerId == b.migratedPeerId);
|
|
|
|
};
|
|
|
|
const auto countDistanceInData = [&](const Key &a, const Key &b) {
|
|
|
|
return [&](const SparseIdsMergedSlice &data) {
|
|
|
|
return inSameDomain(a, b)
|
|
|
|
? data.distance(a, b)
|
2018-09-21 16:28:46 +00:00
|
|
|
: std::optional<int>();
|
2017-12-09 10:02:51 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (key == data->playlistRequestedKey) {
|
|
|
|
return true;
|
|
|
|
} else if (!data->playlistSliceKey
|
|
|
|
|| !data->playlistRequestedKey
|
|
|
|
|| *data->playlistRequestedKey != *data->playlistSliceKey) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto distance = data->playlistSlice
|
|
|
|
| countDistanceInData(*key, *data->playlistRequestedKey)
|
|
|
|
| func::abs;
|
|
|
|
if (distance) {
|
|
|
|
return (*distance < kIdsPreloadAfter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return !data->playlistSlice;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::validatePlaylist(not_null<Data*> data) {
|
|
|
|
if (const auto key = playlistKey(data)) {
|
|
|
|
data->playlistRequestedKey = key;
|
|
|
|
SharedMediaMergedViewer(
|
2020-06-08 09:06:50 +00:00
|
|
|
&data->history->session(),
|
2017-12-09 10:02:51 +00:00
|
|
|
SharedMediaMergedKey(*key, data->overview),
|
|
|
|
kIdsLimit,
|
|
|
|
kIdsLimit
|
|
|
|
) | rpl::start_with_next([=](SparseIdsMergedSlice &&update) {
|
|
|
|
data->playlistSlice = std::move(update);
|
|
|
|
data->playlistSliceKey = key;
|
|
|
|
playlistUpdated(data);
|
|
|
|
}, data->playlistLifetime);
|
|
|
|
} else {
|
2018-09-21 16:28:46 +00:00
|
|
|
data->playlistSlice = std::nullopt;
|
|
|
|
data->playlistSliceKey = data->playlistRequestedKey = std::nullopt;
|
2017-12-09 10:02:51 +00:00
|
|
|
playlistUpdated(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Instance::playlistKey(not_null<Data*> data) const
|
2018-09-21 16:28:46 +00:00
|
|
|
-> std::optional<SliceKey> {
|
2017-12-09 10:02:51 +00:00
|
|
|
const auto contextId = data->current.contextId();
|
|
|
|
const auto history = data->history;
|
2017-12-09 15:13:06 +00:00
|
|
|
if (!contextId || !history || !IsServerMsgId(contextId.msg)) {
|
2017-12-09 10:02:51 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto universalId = (contextId.channel == history->channelId())
|
|
|
|
? contextId.msg
|
|
|
|
: (contextId.msg - ServerMaxMsgId);
|
|
|
|
return SliceKey(
|
|
|
|
data->history->peer->id,
|
|
|
|
data->migrated ? data->migrated->peer->id : 0,
|
|
|
|
universalId);
|
|
|
|
}
|
|
|
|
|
|
|
|
HistoryItem *Instance::itemByIndex(not_null<Data*> data, int index) {
|
|
|
|
if (!data->playlistSlice
|
|
|
|
|| index < 0
|
|
|
|
|| index >= data->playlistSlice->size()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-06-08 09:06:50 +00:00
|
|
|
Assert(data->history != nullptr);
|
2017-12-09 10:02:51 +00:00
|
|
|
const auto fullId = (*data->playlistSlice)[index];
|
2020-06-08 09:06:50 +00:00
|
|
|
return data->history->owner().message(fullId);
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2017-12-08 18:27:28 +00:00
|
|
|
bool Instance::moveInPlaylist(
|
|
|
|
not_null<Data*> data,
|
|
|
|
int delta,
|
|
|
|
bool autonext) {
|
2017-12-09 10:02:51 +00:00
|
|
|
if (!data->playlistIndex) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const auto newIndex = *data->playlistIndex + delta;
|
|
|
|
if (const auto item = itemByIndex(data, newIndex)) {
|
2018-01-14 16:02:25 +00:00
|
|
|
if (const auto media = item->media()) {
|
|
|
|
if (const auto document = media->document()) {
|
2017-12-09 10:02:51 +00:00
|
|
|
if (autonext) {
|
|
|
|
_switchToNextNotifier.notify({
|
|
|
|
data->current,
|
|
|
|
item->fullId()
|
|
|
|
});
|
|
|
|
}
|
2018-01-21 14:49:42 +00:00
|
|
|
if (document->isAudioFile()
|
|
|
|
|| document->isVoiceMessage()
|
|
|
|
|| document->isVideoMessage()) {
|
2017-12-09 10:02:51 +00:00
|
|
|
play(AudioMsgId(document, item->fullId()));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-08 18:27:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-05-19 18:11:33 +00:00
|
|
|
|
2017-12-08 18:27:28 +00:00
|
|
|
bool Instance::previousAvailable(AudioMsgId::Type type) const {
|
2017-12-09 10:02:51 +00:00
|
|
|
const auto data = getData(type);
|
|
|
|
Assert(data != nullptr);
|
|
|
|
return data->playlistIndex
|
|
|
|
&& data->playlistSlice
|
|
|
|
&& (*data->playlistIndex > 0);
|
2017-12-08 18:27:28 +00:00
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
|
2017-12-08 18:27:28 +00:00
|
|
|
bool Instance::nextAvailable(AudioMsgId::Type type) const {
|
2017-12-09 10:02:51 +00:00
|
|
|
const auto data = getData(type);
|
|
|
|
Assert(data != nullptr);
|
|
|
|
return data->playlistIndex
|
|
|
|
&& data->playlistSlice
|
|
|
|
&& (*data->playlistIndex + 1 < data->playlistSlice->size());
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2017-12-08 18:27:28 +00:00
|
|
|
rpl::producer<> Media::Player::Instance::playlistChanges(
|
|
|
|
AudioMsgId::Type type) const {
|
2017-12-09 10:02:51 +00:00
|
|
|
const auto data = getData(type);
|
|
|
|
Assert(data != nullptr);
|
|
|
|
return data->playlistChanges.events();
|
2017-12-08 18:27:28 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 16:04:26 +00:00
|
|
|
Instance *instance() {
|
2017-05-19 18:11:33 +00:00
|
|
|
Expects(SingleInstance != nullptr);
|
2016-09-23 16:04:26 +00:00
|
|
|
return SingleInstance;
|
|
|
|
}
|
|
|
|
|
2017-05-19 18:11:33 +00:00
|
|
|
void Instance::play(AudioMsgId::Type type) {
|
2019-02-28 21:03:25 +00:00
|
|
|
if (const auto data = getData(type)) {
|
2019-03-26 08:54:51 +00:00
|
|
|
if (!data->streamed || IsStopped(getState(type).state)) {
|
2017-05-19 18:11:33 +00:00
|
|
|
play(data->current);
|
2019-03-26 08:54:51 +00:00
|
|
|
} else {
|
2019-12-11 12:09:21 +00:00
|
|
|
if (data->streamed->instance.active()) {
|
|
|
|
data->streamed->instance.resume();
|
2019-03-26 08:54:51 +00:00
|
|
|
}
|
|
|
|
emitUpdate(type);
|
2017-05-19 18:11:33 +00:00
|
|
|
}
|
2018-10-31 06:51:19 +00:00
|
|
|
data->resumeOnCallEnd = false;
|
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::play(const AudioMsgId &audioId) {
|
2017-12-10 10:26:58 +00:00
|
|
|
const auto document = audioId.audio();
|
2019-03-01 12:22:47 +00:00
|
|
|
if (!document) {
|
2016-09-23 16:04:26 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-03-26 08:54:51 +00:00
|
|
|
if (document->isAudioFile()
|
|
|
|
|| document->isVoiceMessage()
|
|
|
|
|| document->isVideoMessage()) {
|
2019-12-28 14:56:06 +00:00
|
|
|
auto shared = document->owner().streaming().sharedDocument(
|
2019-04-10 11:26:15 +00:00
|
|
|
document,
|
|
|
|
audioId.contextId());
|
2019-12-11 10:15:48 +00:00
|
|
|
if (!shared) {
|
2019-02-28 21:03:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-12-11 10:15:48 +00:00
|
|
|
playStreamed(audioId, std::move(shared));
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
2018-03-09 21:32:52 +00:00
|
|
|
if (document->isVoiceMessage() || document->isVideoMessage()) {
|
2019-01-25 14:37:28 +00:00
|
|
|
document->owner().markMediaRead(document);
|
2018-03-09 21:32:52 +00:00
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
void Instance::playPause(const AudioMsgId &audioId) {
|
|
|
|
const auto now = current(audioId.type());
|
|
|
|
if (now.audio() == audioId.audio()
|
|
|
|
&& now.contextId() == audioId.contextId()) {
|
|
|
|
playPause(audioId.type());
|
|
|
|
} else {
|
|
|
|
play(audioId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::playStreamed(
|
|
|
|
const AudioMsgId &audioId,
|
2019-12-11 10:15:48 +00:00
|
|
|
std::shared_ptr<Streaming::Document> shared) {
|
2019-02-28 21:03:25 +00:00
|
|
|
Expects(audioId.audio() != nullptr);
|
|
|
|
|
|
|
|
const auto data = getData(audioId.type());
|
|
|
|
Assert(data != nullptr);
|
2019-03-26 08:54:51 +00:00
|
|
|
|
2020-02-06 09:19:33 +00:00
|
|
|
clearStreamed(data, data->current.audio() != audioId.audio());
|
2019-02-28 21:03:25 +00:00
|
|
|
data->streamed = std::make_unique<Streamed>(
|
|
|
|
audioId,
|
2019-12-11 10:15:48 +00:00
|
|
|
std::move(shared));
|
2019-12-18 18:26:17 +00:00
|
|
|
data->streamed->instance.lockPlayer();
|
2019-02-28 21:03:25 +00:00
|
|
|
|
2019-12-11 12:09:21 +00:00
|
|
|
data->streamed->instance.player().updates(
|
2019-02-28 21:03:25 +00:00
|
|
|
) | rpl::start_with_next_error([=](Streaming::Update &&update) {
|
|
|
|
handleStreamingUpdate(data, std::move(update));
|
2019-06-04 15:59:26 +00:00
|
|
|
}, [=](Streaming::Error &&error) {
|
2019-02-28 21:03:25 +00:00
|
|
|
handleStreamingError(data, std::move(error));
|
2019-12-11 10:15:48 +00:00
|
|
|
}, data->streamed->lifetime);
|
2019-02-28 21:03:25 +00:00
|
|
|
|
2019-12-11 12:09:21 +00:00
|
|
|
data->streamed->instance.play(streamingOptions(audioId));
|
2019-02-28 21:03:25 +00:00
|
|
|
|
|
|
|
emitUpdate(audioId.type());
|
|
|
|
}
|
|
|
|
|
|
|
|
Streaming::PlaybackOptions Instance::streamingOptions(
|
|
|
|
const AudioMsgId &audioId,
|
|
|
|
crl::time position) {
|
2019-03-26 08:54:51 +00:00
|
|
|
const auto document = audioId.audio();
|
2019-02-28 21:03:25 +00:00
|
|
|
auto result = Streaming::PlaybackOptions();
|
2019-03-26 08:54:51 +00:00
|
|
|
result.mode = (document && document->isVideoMessage())
|
|
|
|
? Streaming::Mode::Both
|
|
|
|
: Streaming::Mode::Audio;
|
2019-03-26 12:50:00 +00:00
|
|
|
result.speed = (document
|
|
|
|
&& (document->isVoiceMessage() || document->isVideoMessage())
|
|
|
|
&& Global::VoiceMsgPlaybackDoubled())
|
|
|
|
? kVoicePlaybackSpeedMultiplier
|
|
|
|
: 1.;
|
2019-02-28 21:03:25 +00:00
|
|
|
result.audioId = audioId;
|
2019-12-26 14:14:35 +00:00
|
|
|
if (position >= 0) {
|
|
|
|
result.position = position;
|
|
|
|
} else if (document) {
|
|
|
|
auto &settings = document->session().settings();
|
|
|
|
result.position = settings.mediaLastPlaybackPosition(document->id);
|
|
|
|
settings.setMediaLastPlaybackPosition(document->id, 0);
|
|
|
|
} else {
|
|
|
|
result.position = 0;
|
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-02-10 22:37:37 +00:00
|
|
|
void Instance::pause(AudioMsgId::Type type) {
|
2019-02-28 21:03:25 +00:00
|
|
|
if (const auto data = getData(type)) {
|
|
|
|
if (data->streamed) {
|
2019-12-11 12:09:21 +00:00
|
|
|
if (data->streamed->instance.active()) {
|
|
|
|
data->streamed->instance.pause();
|
2019-03-04 11:28:52 +00:00
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
emitUpdate(type);
|
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-19 18:11:33 +00:00
|
|
|
void Instance::stop(AudioMsgId::Type type) {
|
2018-10-31 06:51:19 +00:00
|
|
|
if (const auto data = getData(type)) {
|
2019-02-28 21:03:25 +00:00
|
|
|
if (data->streamed) {
|
2019-03-26 08:54:51 +00:00
|
|
|
clearStreamed(data);
|
2019-02-28 21:03:25 +00:00
|
|
|
}
|
2018-10-31 06:51:19 +00:00
|
|
|
data->resumeOnCallEnd = false;
|
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2017-05-19 18:11:33 +00:00
|
|
|
void Instance::playPause(AudioMsgId::Type type) {
|
2019-02-28 21:03:25 +00:00
|
|
|
if (const auto data = getData(type)) {
|
2019-03-26 08:54:51 +00:00
|
|
|
if (!data->streamed) {
|
|
|
|
play(data->current);
|
|
|
|
} else {
|
2019-12-11 12:09:21 +00:00
|
|
|
auto &streamed = data->streamed->instance;
|
|
|
|
if (!streamed.active()) {
|
|
|
|
streamed.play(streamingOptions(data->streamed->id));
|
|
|
|
} else if (streamed.paused()) {
|
|
|
|
streamed.resume();
|
2019-02-28 21:03:25 +00:00
|
|
|
} else {
|
2019-12-11 12:09:21 +00:00
|
|
|
streamed.pause();
|
2019-02-28 21:03:25 +00:00
|
|
|
}
|
|
|
|
emitUpdate(type);
|
2017-05-19 18:11:33 +00:00
|
|
|
}
|
2018-10-31 06:51:19 +00:00
|
|
|
data->resumeOnCallEnd = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::pauseOnCall(AudioMsgId::Type type) {
|
2019-02-28 21:03:25 +00:00
|
|
|
const auto state = getState(type);
|
2018-10-31 06:51:19 +00:00
|
|
|
if (!state.id
|
|
|
|
|| IsStopped(state.state)
|
|
|
|
|| IsPaused(state.state)
|
|
|
|
|| state.state == State::Pausing) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pause(type);
|
|
|
|
if (const auto data = getData(type)) {
|
|
|
|
data->resumeOnCallEnd = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::resumeOnCall(AudioMsgId::Type type) {
|
|
|
|
if (const auto data = getData(type)) {
|
|
|
|
if (data->resumeOnCallEnd) {
|
|
|
|
data->resumeOnCallEnd = false;
|
2018-11-09 07:26:33 +00:00
|
|
|
play(type);
|
2018-10-31 06:51:19 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2017-05-21 13:16:39 +00:00
|
|
|
bool Instance::next(AudioMsgId::Type type) {
|
2018-10-31 06:51:19 +00:00
|
|
|
if (const auto data = getData(type)) {
|
2017-05-21 17:08:59 +00:00
|
|
|
return moveInPlaylist(data, 1, false);
|
2017-05-19 18:11:33 +00:00
|
|
|
}
|
2017-05-21 13:16:39 +00:00
|
|
|
return false;
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2017-05-21 13:16:39 +00:00
|
|
|
bool Instance::previous(AudioMsgId::Type type) {
|
2018-10-31 06:51:19 +00:00
|
|
|
if (const auto data = getData(type)) {
|
2017-05-21 17:08:59 +00:00
|
|
|
return moveInPlaylist(data, -1, false);
|
2017-05-19 18:11:33 +00:00
|
|
|
}
|
2017-05-21 13:16:39 +00:00
|
|
|
return false;
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2017-05-19 18:11:33 +00:00
|
|
|
void Instance::playPauseCancelClicked(AudioMsgId::Type type) {
|
|
|
|
if (isSeeking(type)) {
|
2016-10-09 17:08:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
const auto data = getData(type);
|
|
|
|
if (!data) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto state = getState(type);
|
|
|
|
const auto stopped = IsStoppedOrStopping(state.state);
|
|
|
|
const auto showPause = ShowPauseIcon(state.state);
|
|
|
|
const auto audio = state.id.audio();
|
|
|
|
if (audio && audio->loading() && !data->streamed) {
|
2016-10-09 17:08:16 +00:00
|
|
|
audio->cancel();
|
|
|
|
} else if (showPause) {
|
2017-05-19 18:11:33 +00:00
|
|
|
pause(type);
|
2016-10-09 17:08:16 +00:00
|
|
|
} else {
|
2017-05-19 18:11:33 +00:00
|
|
|
play(type);
|
2016-10-09 17:08:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 22:37:37 +00:00
|
|
|
void Instance::startSeeking(AudioMsgId::Type type) {
|
2017-05-19 18:11:33 +00:00
|
|
|
if (auto data = getData(type)) {
|
|
|
|
data->seeking = data->current;
|
2017-02-10 22:37:37 +00:00
|
|
|
}
|
|
|
|
pause(type);
|
2019-02-28 21:03:25 +00:00
|
|
|
emitUpdate(type);
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
void Instance::finishSeeking(AudioMsgId::Type type, float64 progress) {
|
|
|
|
if (const auto data = getData(type)) {
|
2019-12-11 10:15:48 +00:00
|
|
|
if (const auto streamed = data->streamed.get()) {
|
2019-12-11 12:09:21 +00:00
|
|
|
const auto &info = streamed->instance.info();
|
2019-12-11 10:15:48 +00:00
|
|
|
const auto duration = info.audio.state.duration;
|
2019-02-28 21:03:25 +00:00
|
|
|
if (duration != kTimeUnknown) {
|
|
|
|
const auto position = crl::time(std::round(
|
|
|
|
std::clamp(progress, 0., 1.) * duration));
|
2019-12-11 12:09:21 +00:00
|
|
|
streamed->instance.play(streamingOptions(
|
2019-12-11 10:15:48 +00:00
|
|
|
streamed->id,
|
2019-02-28 21:03:25 +00:00
|
|
|
position));
|
|
|
|
emitUpdate(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cancelSeeking(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::cancelSeeking(AudioMsgId::Type type) {
|
|
|
|
if (const auto data = getData(type)) {
|
2017-05-19 18:11:33 +00:00
|
|
|
data->seeking = AudioMsgId();
|
2017-02-10 22:37:37 +00:00
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
emitUpdate(type);
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
|
|
|
|
2019-03-26 12:50:00 +00:00
|
|
|
void Instance::updateVoicePlaybackSpeed() {
|
|
|
|
if (const auto data = getData(AudioMsgId::Type::Voice)) {
|
|
|
|
if (const auto streamed = data->streamed.get()) {
|
2019-12-11 12:09:21 +00:00
|
|
|
streamed->instance.setSpeed(Global::VoiceMsgPlaybackDoubled()
|
2019-03-26 12:50:00 +00:00
|
|
|
? kVoicePlaybackSpeedMultiplier
|
|
|
|
: 1.);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-23 16:04:26 +00:00
|
|
|
void Instance::documentLoadProgress(DocumentData *document) {
|
2017-12-10 10:26:58 +00:00
|
|
|
const auto type = document->isAudioFile()
|
2017-12-09 10:02:51 +00:00
|
|
|
? AudioMsgId::Type::Song
|
|
|
|
: AudioMsgId::Type::Voice;
|
2019-02-28 21:03:25 +00:00
|
|
|
emitUpdate(type, [&](const AudioMsgId &audioId) {
|
2016-09-23 16:04:26 +00:00
|
|
|
return (audioId.audio() == document);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
void Instance::emitUpdate(AudioMsgId::Type type) {
|
|
|
|
emitUpdate(type, [](const AudioMsgId &playing) { return true; });
|
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
TrackState Instance::getState(AudioMsgId::Type type) const {
|
|
|
|
if (const auto data = getData(type)) {
|
|
|
|
if (data->streamed) {
|
2019-12-11 12:09:21 +00:00
|
|
|
return data->streamed->instance.player().prepareLegacyState();
|
2019-02-28 21:03:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-26 08:54:51 +00:00
|
|
|
return TrackState();
|
|
|
|
}
|
|
|
|
|
2019-12-11 12:09:21 +00:00
|
|
|
Streaming::Instance *Instance::roundVideoStreamed(HistoryItem *item) const {
|
2019-03-26 08:54:51 +00:00
|
|
|
if (!item) {
|
|
|
|
return nullptr;
|
|
|
|
} else if (const auto data = getData(AudioMsgId::Type::Voice)) {
|
|
|
|
if (const auto streamed = data->streamed.get()) {
|
|
|
|
if (streamed->id.contextId() == item->fullId()) {
|
2019-12-11 12:09:21 +00:00
|
|
|
const auto player = &streamed->instance.player();
|
2019-03-26 08:54:51 +00:00
|
|
|
if (player->ready() && !player->videoSize().isEmpty()) {
|
2019-12-11 12:09:21 +00:00
|
|
|
return &streamed->instance;
|
2019-03-26 08:54:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
View::PlaybackProgress *Instance::roundVideoPlayback(
|
|
|
|
HistoryItem *item) const {
|
2019-12-11 10:15:48 +00:00
|
|
|
return roundVideoStreamed(item)
|
2019-03-26 08:54:51 +00:00
|
|
|
? &getData(AudioMsgId::Type::Voice)->streamed->progress
|
|
|
|
: nullptr;
|
2019-02-28 21:03:25 +00:00
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
template <typename CheckCallback>
|
|
|
|
void Instance::emitUpdate(AudioMsgId::Type type, CheckCallback check) {
|
|
|
|
if (const auto data = getData(type)) {
|
|
|
|
const auto state = getState(type);
|
|
|
|
if (!state.id || !check(state.id)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setCurrent(state.id);
|
2019-12-11 10:15:48 +00:00
|
|
|
if (const auto streamed = data->streamed.get()) {
|
2019-12-11 12:09:21 +00:00
|
|
|
if (!streamed->instance.info().video.size.isEmpty()) {
|
2019-12-11 10:15:48 +00:00
|
|
|
streamed->progress.updateState(state);
|
|
|
|
}
|
2019-03-26 08:54:51 +00:00
|
|
|
}
|
2019-05-11 10:46:04 +00:00
|
|
|
_updatedNotifier.fire_copy({state});
|
2017-05-19 18:11:33 +00:00
|
|
|
if (data->isPlaying && state.state == State::StoppedAtEnd) {
|
|
|
|
if (data->repeatEnabled) {
|
|
|
|
play(data->current);
|
2017-05-21 17:08:59 +00:00
|
|
|
} else if (!moveInPlaylist(data, 1, true)) {
|
2017-05-21 13:16:39 +00:00
|
|
|
_tracksFinishedNotifier.notify(type);
|
2017-02-10 22:37:37 +00:00
|
|
|
}
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
2019-03-05 13:56:27 +00:00
|
|
|
data->isPlaying = !IsStopped(state.state);
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 12:15:14 +00:00
|
|
|
void Instance::setupShortcuts() {
|
|
|
|
Shortcuts::Requests(
|
|
|
|
) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
|
|
|
using Command = Shortcuts::Command;
|
|
|
|
request->check(Command::MediaPlay) && request->handle([=] {
|
|
|
|
play();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
request->check(Command::MediaPause) && request->handle([=] {
|
|
|
|
pause();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
request->check(Command::MediaPlayPause) && request->handle([=] {
|
|
|
|
playPause();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
request->check(Command::MediaStop) && request->handle([=] {
|
|
|
|
stop();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
request->check(Command::MediaPrevious) && request->handle([=] {
|
|
|
|
previous();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
request->check(Command::MediaNext) && request->handle([=] {
|
|
|
|
next();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}, _lifetime);
|
|
|
|
}
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
void Instance::handleStreamingUpdate(
|
|
|
|
not_null<Data*> data,
|
|
|
|
Streaming::Update &&update) {
|
|
|
|
using namespace Streaming;
|
|
|
|
|
2019-03-26 08:54:51 +00:00
|
|
|
update.data.match([&](Information &update) {
|
2019-12-11 10:15:48 +00:00
|
|
|
if (!update.video.size.isEmpty()) {
|
2019-03-26 08:54:51 +00:00
|
|
|
data->streamed->progress.setValueChangedCallback([=](
|
|
|
|
float64,
|
|
|
|
float64) {
|
|
|
|
requestRoundVideoRepaint();
|
|
|
|
});
|
2019-06-06 10:21:40 +00:00
|
|
|
App::wnd()->sessionController()->enableGifPauseReason(
|
2019-03-26 08:54:51 +00:00
|
|
|
Window::GifPauseReason::RoundPlaying);
|
|
|
|
requestRoundVideoResize();
|
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
emitUpdate(data->type);
|
|
|
|
}, [&](PreloadedVideo &update) {
|
2019-03-26 08:54:51 +00:00
|
|
|
//emitUpdate(data->type, [](AudioMsgId) { return true; });
|
2019-02-28 21:03:25 +00:00
|
|
|
}, [&](UpdateVideo &update) {
|
2019-03-26 08:54:51 +00:00
|
|
|
emitUpdate(data->type);
|
|
|
|
}, [&](PreloadedAudio &update) {
|
2019-02-28 21:03:25 +00:00
|
|
|
//emitUpdate(data->type, [](AudioMsgId) { return true; });
|
|
|
|
}, [&](UpdateAudio &update) {
|
|
|
|
emitUpdate(data->type);
|
|
|
|
}, [&](WaitingForData) {
|
|
|
|
}, [&](MutedByOther) {
|
|
|
|
}, [&](Finished) {
|
|
|
|
emitUpdate(data->type);
|
2019-12-11 12:09:21 +00:00
|
|
|
if (data->streamed && data->streamed->instance.player().finished()) {
|
2019-03-26 08:54:51 +00:00
|
|
|
clearStreamed(data);
|
2019-03-04 11:28:52 +00:00
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-03-26 08:54:51 +00:00
|
|
|
HistoryItem *Instance::roundVideoItem() const {
|
|
|
|
const auto data = getData(AudioMsgId::Type::Voice);
|
|
|
|
return (data->streamed
|
2020-06-08 09:06:50 +00:00
|
|
|
&& !data->streamed->instance.info().video.size.isEmpty()
|
|
|
|
&& data->history)
|
|
|
|
? data->history->owner().message(data->streamed->id.contextId())
|
2019-03-26 08:54:51 +00:00
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::requestRoundVideoResize() const {
|
|
|
|
if (const auto item = roundVideoItem()) {
|
2020-06-08 09:06:50 +00:00
|
|
|
item->history()->owner().requestItemResize(item);
|
2019-03-26 08:54:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Instance::requestRoundVideoRepaint() const {
|
|
|
|
if (const auto item = roundVideoItem()) {
|
2020-06-08 09:06:50 +00:00
|
|
|
item->history()->owner().requestItemRepaint(item);
|
2019-03-26 08:54:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-28 21:03:25 +00:00
|
|
|
void Instance::handleStreamingError(
|
|
|
|
not_null<Data*> data,
|
|
|
|
Streaming::Error &&error) {
|
2019-03-05 13:56:27 +00:00
|
|
|
Expects(data->streamed != nullptr);
|
|
|
|
|
|
|
|
const auto document = data->streamed->id.audio();
|
|
|
|
const auto contextId = data->streamed->id.contextId();
|
|
|
|
if (error == Streaming::Error::NotStreamable) {
|
|
|
|
DocumentSaveClickHandler::Save(
|
|
|
|
(contextId ? contextId : ::Data::FileOrigin()),
|
2019-03-11 14:35:11 +00:00
|
|
|
document);
|
2019-03-05 13:56:27 +00:00
|
|
|
} else if (error == Streaming::Error::OpenFailed) {
|
|
|
|
DocumentSaveClickHandler::Save(
|
|
|
|
(contextId ? contextId : ::Data::FileOrigin()),
|
|
|
|
document,
|
2019-03-11 14:35:11 +00:00
|
|
|
DocumentSaveClickHandler::Mode::ToFile);
|
2019-03-05 13:56:27 +00:00
|
|
|
}
|
2019-03-04 11:28:52 +00:00
|
|
|
emitUpdate(data->type);
|
2019-12-11 12:09:21 +00:00
|
|
|
if (data->streamed && data->streamed->instance.player().failed()) {
|
2019-03-26 08:54:51 +00:00
|
|
|
clearStreamed(data);
|
2019-03-04 11:28:52 +00:00
|
|
|
}
|
2019-02-28 21:03:25 +00:00
|
|
|
}
|
|
|
|
|
2016-09-23 16:04:26 +00:00
|
|
|
} // namespace Player
|
|
|
|
} // namespace Media
|