|
|
@ -80,7 +80,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
spanTime.innerText = (doc.duration + '').toHHMMSS(false); |
|
|
|
spanTime.innerText = (doc.duration + '').toHHMMSS(false); |
|
|
|
|
|
|
|
|
|
|
|
if(!noPlayButton && doc.type !== 'round') { |
|
|
|
if(!noPlayButton && doc.type !== 'round') { |
|
|
|
if(canAutoplay) { |
|
|
|
if(canAutoplay && !noAutoDownload) { |
|
|
|
spanTime.classList.add('tgico', 'can-autoplay'); |
|
|
|
spanTime.classList.add('tgico', 'can-autoplay'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
needPlayButton = true; |
|
|
|
needPlayButton = true; |
|
|
@ -232,6 +232,15 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
attachClickEvent(canvas, (e) => { |
|
|
|
attachClickEvent(canvas, (e) => { |
|
|
|
cancelEvent(e); |
|
|
|
cancelEvent(e); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ! костыль
|
|
|
|
|
|
|
|
if(preloader && !preloader.detached) { |
|
|
|
|
|
|
|
preloader.onClick(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(globalVideo.readyState < 2) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(globalVideo.paused) { |
|
|
|
if(globalVideo.paused) { |
|
|
|
globalVideo.play(); |
|
|
|
globalVideo.play(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -316,7 +325,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let f = noAutoDownload && photoRes?.preloader?.loadFunc; |
|
|
|
let loadPhotoThumbFunc = noAutoDownload && photoRes?.preloader?.loadFunc; |
|
|
|
const load = () => { |
|
|
|
const load = () => { |
|
|
|
if(preloader && noAutoDownload && !withoutPreloader) { |
|
|
|
if(preloader && noAutoDownload && !withoutPreloader) { |
|
|
|
preloader.construct(); |
|
|
|
preloader.construct(); |
|
|
@ -348,11 +357,15 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
if(preloader) { |
|
|
|
if(preloader) { |
|
|
|
preloader.detach(); |
|
|
|
preloader.detach(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!deferred.isFulfilled) { |
|
|
|
|
|
|
|
deferred.resolve(); |
|
|
|
|
|
|
|
} |
|
|
|
}, {once: true}); |
|
|
|
}, {once: true}); |
|
|
|
|
|
|
|
|
|
|
|
if(!noAutoDownload && f) { |
|
|
|
if(!noAutoDownload && loadPhotoThumbFunc) { |
|
|
|
f(); |
|
|
|
loadPhotoThumbFunc(); |
|
|
|
f = null; |
|
|
|
loadPhotoThumbFunc = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
noAutoDownload = undefined; |
|
|
|
noAutoDownload = undefined; |
|
|
@ -372,6 +385,10 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
if(group) { |
|
|
|
if(group) { |
|
|
|
animationIntersector.addAnimation(video, group); |
|
|
|
animationIntersector.addAnimation(video, group); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(preloader) { |
|
|
|
|
|
|
|
preloader.detach(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deferred.resolve(); |
|
|
|
deferred.resolve(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -381,11 +398,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
spanTime.innerText = (video.duration - video.currentTime + '').toHHMMSS(false); |
|
|
|
spanTime.innerText = (video.duration - video.currentTime + '').toHHMMSS(false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
video.addEventListener('error', (e) => { |
|
|
|
|
|
|
|
deferred.resolve(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
video.muted = true; |
|
|
|
video.muted = true; |
|
|
|
video.loop = true; |
|
|
|
video.loop = true; |
|
|
|
//video.play();
|
|
|
|
//video.play();
|
|
|
@ -823,7 +836,7 @@ export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withT |
|
|
|
preloader = message.media.preloader; |
|
|
|
preloader = message.media.preloader; |
|
|
|
preloader.attach(container); |
|
|
|
preloader.attach(container); |
|
|
|
noAutoDownload = undefined; |
|
|
|
noAutoDownload = undefined; |
|
|
|
} else { |
|
|
|
} else if(!cacheContext.downloaded) { |
|
|
|
preloader = new ProgressivePreloader({ |
|
|
|
preloader = new ProgressivePreloader({ |
|
|
|
attachMethod: 'prepend' |
|
|
|
attachMethod: 'prepend' |
|
|
|
}); |
|
|
|
}); |
|
|
@ -834,8 +847,6 @@ export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withT |
|
|
|
appDocsManager.downloadDoc(photo, /* undefined, */lazyLoadQueue?.queueId) : |
|
|
|
appDocsManager.downloadDoc(photo, /* undefined, */lazyLoadQueue?.queueId) : |
|
|
|
appPhotosManager.preloadPhoto(photo, size, lazyLoadQueue?.queueId, noAutoDownload); |
|
|
|
appPhotosManager.preloadPhoto(photo, size, lazyLoadQueue?.queueId, noAutoDownload); |
|
|
|
|
|
|
|
|
|
|
|
noAutoDownload = undefined; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return promise; |
|
|
|
return promise; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -846,24 +857,36 @@ export function wrapPhoto({photo, message, container, boxWidth, boxHeight, withT |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let loadPromise: Promise<any>; |
|
|
|
let loadPromise: Promise<any>; |
|
|
|
|
|
|
|
const canAttachPreloader = ( |
|
|
|
|
|
|
|
(size as PhotoSize.photoSize).w >= 150 && |
|
|
|
|
|
|
|
(size as PhotoSize.photoSize).h >= 150 |
|
|
|
|
|
|
|
) || noAutoDownload; |
|
|
|
const load = () => { |
|
|
|
const load = () => { |
|
|
|
if(noAutoDownload && !withoutPreloader) { |
|
|
|
if(noAutoDownload && !withoutPreloader && preloader) { |
|
|
|
preloader.construct(); |
|
|
|
preloader.construct(); |
|
|
|
preloader.setManual(); |
|
|
|
preloader.setManual(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const promise = getDownloadPromise(); |
|
|
|
const promise = getDownloadPromise(); |
|
|
|
|
|
|
|
|
|
|
|
if(!cacheContext.downloaded && !withoutPreloader && (size as PhotoSize.photoSize).w >= 150 && (size as PhotoSize.photoSize).h >= 150) { |
|
|
|
if(preloader && |
|
|
|
|
|
|
|
!cacheContext.downloaded && |
|
|
|
|
|
|
|
!withoutPreloader && |
|
|
|
|
|
|
|
canAttachPreloader |
|
|
|
|
|
|
|
) { |
|
|
|
preloader.attach(container, false, promise); |
|
|
|
preloader.attach(container, false, promise); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
noAutoDownload = undefined; |
|
|
|
|
|
|
|
|
|
|
|
const renderPromise = promise.then(onLoad); |
|
|
|
const renderPromise = promise.then(onLoad); |
|
|
|
renderPromise.catch(() => {}); |
|
|
|
renderPromise.catch(() => {}); |
|
|
|
return {download: promise, render: renderPromise}; |
|
|
|
return {download: promise, render: renderPromise}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
preloader.setDownloadFunction(load); |
|
|
|
if(preloader) { |
|
|
|
|
|
|
|
preloader.setDownloadFunction(load); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(cacheContext.downloaded) { |
|
|
|
if(cacheContext.downloaded) { |
|
|
|
loadThumbPromise = loadPromise = load().render; |
|
|
|
loadThumbPromise = loadPromise = load().render; |
|
|
|