Some fixes for document videos
This commit is contained in:
parent
4180e58f3b
commit
d36ac99d18
@ -408,23 +408,23 @@ export function buildApiDocument(document: GramJs.TypeDocument): ApiDocument | u
|
||||
width: photoSize.w,
|
||||
height: photoSize.h,
|
||||
};
|
||||
}
|
||||
|
||||
if (mimeType.startsWith('image/')) {
|
||||
mediaType = 'photo';
|
||||
if (mimeType.startsWith('image/')) {
|
||||
mediaType = 'photo';
|
||||
|
||||
const imageAttribute = attributes
|
||||
.find((a: any): a is GramJs.DocumentAttributeImageSize => a instanceof GramJs.DocumentAttributeImageSize);
|
||||
const imageAttribute = attributes
|
||||
.find((a: any): a is GramJs.DocumentAttributeImageSize => a instanceof GramJs.DocumentAttributeImageSize);
|
||||
|
||||
if (imageAttribute) {
|
||||
const { w: width, h: height } = imageAttribute;
|
||||
mediaSize = {
|
||||
width,
|
||||
height,
|
||||
};
|
||||
if (imageAttribute) {
|
||||
const { w: width, h: height } = imageAttribute;
|
||||
mediaSize = {
|
||||
width,
|
||||
height,
|
||||
};
|
||||
}
|
||||
} else if (mimeType.startsWith('video/')) {
|
||||
mediaType = 'video';
|
||||
}
|
||||
} else if (mimeType.startsWith('video/')) {
|
||||
mediaType = 'video';
|
||||
}
|
||||
|
||||
return {
|
||||
@ -541,7 +541,7 @@ export function buildWebPage(media: GramJs.TypeMessageMedia): ApiWebPage | undef
|
||||
const { id, photo, document } = media.webpage;
|
||||
|
||||
let video;
|
||||
if (document instanceof GramJs.Document && document.mimeType.startsWith('video')) {
|
||||
if (document instanceof GramJs.Document && document.mimeType.startsWith('video/')) {
|
||||
video = buildVideoFromDocument(document);
|
||||
}
|
||||
|
||||
|
||||
@ -85,6 +85,10 @@ export async function createPosterForVideo(url: string): Promise<string | undefi
|
||||
pause(2000) as Promise<undefined>,
|
||||
new Promise<string>((resolve, reject) => {
|
||||
video.onseeked = () => {
|
||||
if (!video.videoWidth || !video.videoHeight) {
|
||||
resolve(undefined);
|
||||
}
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = video.videoWidth;
|
||||
canvas.height = video.videoHeight;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user