2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Use simple loader for non-streamable file types.

This commit is contained in:
John Preston
2019-04-12 12:00:06 +04:00
parent e1114530ab
commit 8704f6efd0
6 changed files with 45 additions and 20 deletions

View File

@@ -1196,6 +1196,13 @@ bool DocumentData::hasRemoteLocation() const {
return (_dc != 0 && _access != 0);
}
bool DocumentData::useStreamingLoader() const {
return isAnimation()
|| isVideoFile()
|| isAudioFile()
|| isVoiceMessage();
}
bool DocumentData::canBeStreamed() const {
// For now video messages are not streamed.
return hasRemoteLocation() && supportsStreaming() && !isVideoMessage();
@@ -1203,10 +1210,7 @@ bool DocumentData::canBeStreamed() const {
bool DocumentData::canBePlayed() const {
return !_inappPlaybackFailed
&& (isAnimation()
|| isVideoFile()
|| isAudioFile()
|| isVoiceMessage())
&& useStreamingLoader()
&& (loaded() || canBeStreamed());
}
@@ -1220,6 +1224,9 @@ bool DocumentData::inappPlaybackFailed() const {
auto DocumentData::createStreamingLoader(Data::FileOrigin origin) const
-> std::unique_ptr<Media::Streaming::Loader> {
if (!useStreamingLoader()) {
return nullptr;
}
const auto &location = this->location(true);
if (!data().isEmpty()) {
return Media::Streaming::MakeBytesLoader(data());