Enable voice messages streaming.

This commit is contained in:
John Preston 2019-03-06 11:46:56 +04:00
parent 195164d9d4
commit 41c60419f1
4 changed files with 12 additions and 11 deletions

View File

@ -56,7 +56,11 @@ void AutoDownloadBox::setupContent() {
this,
std::move(wrap)));
static const auto kHidden = { Type::Video, Type::Music };
static const auto kHidden = {
Type::Video,
Type::Music,
Type::VoiceMessage
};
const auto values = Ui::CreateChild<base::flat_map<Type, int>>(content);
const auto add = [&](Type type, LangKey label) {

View File

@ -181,7 +181,9 @@ void Full::setBytesLimit(Source source, Type type, int bytesLimit) {
}
bool Full::shouldDownload(Source source, Type type, int fileSize) const {
if (type == Type::Video || type == Type::Music) {
if (type == Type::Video
|| type == Type::Music
|| type == Type::VoiceMessage) {
// With streaming we disable autodownload and hide them in Settings.
return false;
}

View File

@ -115,8 +115,7 @@ AudioMsgId::Type Instance::getActiveType() const {
const auto voiceData = getData(AudioMsgId::Type::Voice);
if (voiceData->current) {
const auto state = getState(voiceData->type);
if (voiceData->current == state.id
&& !IsStoppedOrStopping(state.state)) {
if (!IsStoppedOrStopping(state.state)) {
return voiceData->type;
}
}
@ -355,18 +354,12 @@ void Instance::play(const AudioMsgId &audioId) {
if (!document) {
return;
}
if (document->isAudioFile()) {
if (document->isAudioFile() || document->isVoiceMessage()) {
auto loader = document->createStreamingLoader(audioId.contextId());
if (!loader) {
return;
}
playStreamed(audioId, std::move(loader));
} else if (document->isVoiceMessage()) {
mixer()->play(audioId);
setCurrent(audioId);
if (document->loading()) {
documentLoadProgress(document);
}
} else if (document->isVideoMessage()) {
if (const auto item = App::histItemById(audioId.contextId())) {
App::wnd()->controller()->startRoundVideo(item);

View File

@ -674,6 +674,8 @@ Media::Player::TrackState Player::prepareLegacyState() const {
? crl::time(0)
: document->song()
? document->song()->duration
: document->voice()
? document->voice()->duration
: document->duration();
if (duration > 0) {
result.length = duration * crl::time(1000);