|
|
@ -96,8 +96,14 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
searchContext?: MediaSearchContext, |
|
|
|
searchContext?: MediaSearchContext, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
const isAlbumItem = !(boxWidth && boxHeight); |
|
|
|
const isAlbumItem = !(boxWidth && boxHeight); |
|
|
|
const canAutoplay = (doc.type !== 'video' || (doc.size <= MAX_VIDEO_AUTOPLAY_SIZE && !isAlbumItem)) |
|
|
|
const canAutoplay = doc.sticker || ( |
|
|
|
&& (doc.type === 'gif' ? rootScope.settings.autoPlay.gifs : rootScope.settings.autoPlay.videos); |
|
|
|
( |
|
|
|
|
|
|
|
doc.type !== 'video' || ( |
|
|
|
|
|
|
|
doc.size <= MAX_VIDEO_AUTOPLAY_SIZE && |
|
|
|
|
|
|
|
!isAlbumItem |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) && (doc.type === 'gif' ? rootScope.settings.autoPlay.gifs : rootScope.settings.autoPlay.videos) |
|
|
|
|
|
|
|
); |
|
|
|
let spanTime: HTMLElement, spanPlay: HTMLElement; |
|
|
|
let spanTime: HTMLElement, spanPlay: HTMLElement; |
|
|
|
|
|
|
|
|
|
|
|
if(!noInfo) { |
|
|
|
if(!noInfo) { |
|
|
@ -395,7 +401,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
preloader = (message.media as any).preloader as ProgressivePreloader; |
|
|
|
preloader = (message.media as any).preloader as ProgressivePreloader; |
|
|
|
preloader.attach(container, false); |
|
|
|
preloader.attach(container, false); |
|
|
|
noAutoDownload = undefined; |
|
|
|
noAutoDownload = undefined; |
|
|
|
} else if(!cacheContext.downloaded && !doc.supportsStreaming) { |
|
|
|
} else if(!cacheContext.downloaded && !doc.supportsStreaming && !withoutPreloader) { |
|
|
|
preloader = new ProgressivePreloader({ |
|
|
|
preloader = new ProgressivePreloader({ |
|
|
|
attachMethod: 'prepend' |
|
|
|
attachMethod: 'prepend' |
|
|
|
}); |
|
|
|
}); |
|
|
@ -452,14 +458,16 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let loadPromise: Promise<any> = Promise.resolve(); |
|
|
|
let loadPromise: Promise<any> = Promise.resolve(); |
|
|
|
if(preloader && !isUpload) { |
|
|
|
if((preloader && !isUpload) || withoutPreloader) { |
|
|
|
if(!cacheContext.downloaded && !doc.supportsStreaming) { |
|
|
|
if(!cacheContext.downloaded && !doc.supportsStreaming) { |
|
|
|
const promise = loadPromise = appDocsManager.downloadDoc(doc, lazyLoadQueue?.queueId, noAutoDownload); |
|
|
|
const promise = loadPromise = appDocsManager.downloadDoc(doc, lazyLoadQueue?.queueId, noAutoDownload); |
|
|
|
preloader.attach(container, false, promise); |
|
|
|
if(preloader) { |
|
|
|
|
|
|
|
preloader.attach(container, false, promise); |
|
|
|
|
|
|
|
} |
|
|
|
} else if(doc.supportsStreaming) { |
|
|
|
} else if(doc.supportsStreaming) { |
|
|
|
if(noAutoDownload) { |
|
|
|
if(noAutoDownload) { |
|
|
|
loadPromise = Promise.reject(); |
|
|
|
loadPromise = Promise.reject(); |
|
|
|
} else if(!cacheContext.downloaded) { // * check for uploading video
|
|
|
|
} else if(!cacheContext.downloaded && preloader) { // * check for uploading video
|
|
|
|
preloader.attach(container, false, null); |
|
|
|
preloader.attach(container, false, null); |
|
|
|
video.addEventListener(IS_SAFARI ? 'timeupdate' : 'canplay', () => { |
|
|
|
video.addEventListener(IS_SAFARI ? 'timeupdate' : 'canplay', () => { |
|
|
|
preloader.detach(); |
|
|
|
preloader.detach(); |
|
|
@ -1151,6 +1159,22 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o |
|
|
|
div.dataset.docId = '' + doc.id; |
|
|
|
div.dataset.docId = '' + doc.id; |
|
|
|
div.classList.add('media-sticker-wrapper'); |
|
|
|
div.classList.add('media-sticker-wrapper'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(stickerType === 3) { |
|
|
|
|
|
|
|
return wrapVideo({ |
|
|
|
|
|
|
|
doc, |
|
|
|
|
|
|
|
boxWidth: width, |
|
|
|
|
|
|
|
boxHeight: height, |
|
|
|
|
|
|
|
container: div, |
|
|
|
|
|
|
|
group, |
|
|
|
|
|
|
|
lazyLoadQueue, |
|
|
|
|
|
|
|
middleware, |
|
|
|
|
|
|
|
withoutPreloader: true, |
|
|
|
|
|
|
|
loadPromises, |
|
|
|
|
|
|
|
noPlayButton: true, |
|
|
|
|
|
|
|
noInfo: true |
|
|
|
|
|
|
|
}).loadPromise; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//console.log('wrap sticker', doc, div, onlyThumb);
|
|
|
|
//console.log('wrap sticker', doc, div, onlyThumb);
|
|
|
|
|
|
|
|
|
|
|
|
const cacheContext = appDownloadManager.getCacheContext(doc); |
|
|
|
const cacheContext = appDownloadManager.getCacheContext(doc); |
|
|
|