fix sticker preview
This commit is contained in:
parent
a0ff49e8df
commit
d014abb73f
|
@ -11,11 +11,57 @@
|
|||
{% if media.image %}
|
||||
<img class="mx-auto rounded" src="../{{id}}/thumbnail" alt="{{name}}">
|
||||
{% elif media.video %}
|
||||
<div id="video-warning" class="mx-auto p-4 bg-gray-600 text-gray-300 rounded border text-center hidden break-words">
|
||||
<p> Video {{name}} could not be played!</p>
|
||||
</div>
|
||||
|
||||
<video id="my-video-player" class="mx-auto rounded" controls poster="../{{id}}/thumbnail">
|
||||
<source src="../{{id}}/download" type="{{ media.type }}" />
|
||||
<source src="../{{id}}/download" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
<script>
|
||||
var video = document.querySelector("video");
|
||||
var src = video.firstElementChild
|
||||
|
||||
src.addEventListener('error', function(evt) {
|
||||
console.log(evt);
|
||||
document.getElementById('my-video-player').style.display = 'none';
|
||||
document.getElementById('video-warning').style.display = 'block';
|
||||
});
|
||||
var myFP = fluidPlayer(
|
||||
'my-video-player',{
|
||||
"layoutControls": {
|
||||
"autoPlay": false,
|
||||
"mute": true,
|
||||
"allowTheatre": true,
|
||||
"playPauseAnimation": true,
|
||||
"playbackRateEnabled": true,
|
||||
"allowDownload": false,
|
||||
"playButtonShowing": true,
|
||||
"fillToContainer": true,
|
||||
"posterImage": ""
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
{% elif media.audio %}
|
||||
<audio class="mx-auto" controls autoplay muted src="../{{id}}/download" type="{{ media.type }}"></audio>
|
||||
<div id="audio-warning" class="mx-auto p-4 bg-gray-600 text-gray-300 rounded border text-center hidden break-words">
|
||||
<p> Audio {{name}} could not be played!</p>
|
||||
</div>
|
||||
|
||||
<audio id="my-audio" class="mx-auto" controls muted>
|
||||
<source src="../{{id}}/download" type="audio/mpeg" />
|
||||
</audio>
|
||||
<script>
|
||||
var audio = document.querySelector("audio");
|
||||
var src = audio.firstElementChild
|
||||
|
||||
src.addEventListener('error', function(evt) {
|
||||
console.log(evt);
|
||||
document.getElementById('my-audio').style.display = 'none';
|
||||
document.getElementById('audio-warning').style.display = 'block';
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% if caption %}
|
||||
|
@ -75,43 +121,4 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var myFP = fluidPlayer(
|
||||
'my-video-player',{
|
||||
"layoutControls": {
|
||||
"controlBar": {
|
||||
"autoHideTimeout": 3,
|
||||
"animated": true,
|
||||
"autoHide": true
|
||||
},
|
||||
"logo": {
|
||||
"imageUrl": null,
|
||||
"position": "top left",
|
||||
"clickUrl": null,
|
||||
"opacity": 1
|
||||
},
|
||||
"htmlOnPauseBlock": {
|
||||
"html": null,
|
||||
"height": null,
|
||||
"width": null
|
||||
},
|
||||
"autoPlay": false,
|
||||
"mute": true,
|
||||
"allowTheatre": true,
|
||||
"playPauseAnimation": true,
|
||||
"playbackRateEnabled": true,
|
||||
"allowDownload": false,
|
||||
"playButtonShowing": true,
|
||||
"fillToContainer": true,
|
||||
"posterImage": ""
|
||||
},
|
||||
"vastOptions": {
|
||||
"adList": [],
|
||||
"adCTAText": false,
|
||||
"adCTATextPosition": ""
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
|
|
@ -210,7 +210,7 @@ class Views:
|
|||
)
|
||||
r.enable_chunked_encoding()
|
||||
return r
|
||||
|
||||
|
||||
|
||||
async def download_get(self, req):
|
||||
return await self.handle_request(req)
|
||||
|
@ -244,7 +244,7 @@ class Views:
|
|||
return web.Response(status=404, text="404: Not Found")
|
||||
thumbnail = thumbnail[-1]
|
||||
mime_type = 'image/jpeg'
|
||||
size = thumbnail.size
|
||||
size = thumbnail.size if hasattr(thumbnail, 'size') else len(thumbnail.bytes)
|
||||
file_name = f"{file_id}_thumbnail.jpg"
|
||||
media = types.InputDocumentFileLocation(
|
||||
id=message.document.id,
|
||||
|
|
Loading…
Reference in New Issue