Enable voice messages streaming.
This commit is contained in:
parent
195164d9d4
commit
41c60419f1
|
@ -56,7 +56,11 @@ void AutoDownloadBox::setupContent() {
|
||||||
this,
|
this,
|
||||||
std::move(wrap)));
|
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 values = Ui::CreateChild<base::flat_map<Type, int>>(content);
|
||||||
const auto add = [&](Type type, LangKey label) {
|
const auto add = [&](Type type, LangKey label) {
|
||||||
|
|
|
@ -181,7 +181,9 @@ void Full::setBytesLimit(Source source, Type type, int bytesLimit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Full::shouldDownload(Source source, Type type, int fileSize) const {
|
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.
|
// With streaming we disable autodownload and hide them in Settings.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,7 @@ AudioMsgId::Type Instance::getActiveType() const {
|
||||||
const auto voiceData = getData(AudioMsgId::Type::Voice);
|
const auto voiceData = getData(AudioMsgId::Type::Voice);
|
||||||
if (voiceData->current) {
|
if (voiceData->current) {
|
||||||
const auto state = getState(voiceData->type);
|
const auto state = getState(voiceData->type);
|
||||||
if (voiceData->current == state.id
|
if (!IsStoppedOrStopping(state.state)) {
|
||||||
&& !IsStoppedOrStopping(state.state)) {
|
|
||||||
return voiceData->type;
|
return voiceData->type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,18 +354,12 @@ void Instance::play(const AudioMsgId &audioId) {
|
||||||
if (!document) {
|
if (!document) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (document->isAudioFile()) {
|
if (document->isAudioFile() || document->isVoiceMessage()) {
|
||||||
auto loader = document->createStreamingLoader(audioId.contextId());
|
auto loader = document->createStreamingLoader(audioId.contextId());
|
||||||
if (!loader) {
|
if (!loader) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
playStreamed(audioId, std::move(loader));
|
playStreamed(audioId, std::move(loader));
|
||||||
} else if (document->isVoiceMessage()) {
|
|
||||||
mixer()->play(audioId);
|
|
||||||
setCurrent(audioId);
|
|
||||||
if (document->loading()) {
|
|
||||||
documentLoadProgress(document);
|
|
||||||
}
|
|
||||||
} else if (document->isVideoMessage()) {
|
} else if (document->isVideoMessage()) {
|
||||||
if (const auto item = App::histItemById(audioId.contextId())) {
|
if (const auto item = App::histItemById(audioId.contextId())) {
|
||||||
App::wnd()->controller()->startRoundVideo(item);
|
App::wnd()->controller()->startRoundVideo(item);
|
||||||
|
|
|
@ -674,6 +674,8 @@ Media::Player::TrackState Player::prepareLegacyState() const {
|
||||||
? crl::time(0)
|
? crl::time(0)
|
||||||
: document->song()
|
: document->song()
|
||||||
? document->song()->duration
|
? document->song()->duration
|
||||||
|
: document->voice()
|
||||||
|
? document->voice()->duration
|
||||||
: document->duration();
|
: document->duration();
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
result.length = duration * crl::time(1000);
|
result.length = duration * crl::time(1000);
|
||||||
|
|
Loading…
Reference in New Issue