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