|
|
@ -52,14 +52,16 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
noAutoDownload?: boolean, |
|
|
|
noAutoDownload?: boolean, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
const isAlbumItem = !(boxWidth && boxHeight); |
|
|
|
const isAlbumItem = !(boxWidth && boxHeight); |
|
|
|
const canAutoplay = doc.type !== 'video' || (doc.size <= MAX_VIDEO_AUTOPLAY_SIZE && !isAlbumItem); |
|
|
|
const canAutoplay = (doc.type !== 'video' || (doc.size <= MAX_VIDEO_AUTOPLAY_SIZE && !isAlbumItem)) |
|
|
|
let spanTime: HTMLElement; |
|
|
|
&& (doc.type === 'gif' ? rootScope.settings.autoPlay.gifs : rootScope.settings.autoPlay.videos); |
|
|
|
|
|
|
|
let spanTime: HTMLElement, spanPlay: HTMLElement; |
|
|
|
|
|
|
|
|
|
|
|
if(!noInfo) { |
|
|
|
if(!noInfo) { |
|
|
|
spanTime = document.createElement('span'); |
|
|
|
spanTime = document.createElement('span'); |
|
|
|
spanTime.classList.add('video-time'); |
|
|
|
spanTime.classList.add('video-time'); |
|
|
|
container.append(spanTime); |
|
|
|
container.append(spanTime); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let needPlayButton = false; |
|
|
|
if(doc.type !== 'gif') { |
|
|
|
if(doc.type !== 'gif') { |
|
|
|
spanTime.innerText = (doc.duration + '').toHHMMSS(false); |
|
|
|
spanTime.innerText = (doc.duration + '').toHHMMSS(false); |
|
|
|
|
|
|
|
|
|
|
@ -67,13 +69,22 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
if(canAutoplay) { |
|
|
|
if(canAutoplay) { |
|
|
|
spanTime.classList.add('tgico', 'can-autoplay'); |
|
|
|
spanTime.classList.add('tgico', 'can-autoplay'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const spanPlay = document.createElement('span'); |
|
|
|
needPlayButton = true; |
|
|
|
spanPlay.classList.add('video-play', 'tgico-largeplay', 'btn-circle', 'position-center'); |
|
|
|
|
|
|
|
container.append(spanPlay); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
spanTime.innerText = 'GIF'; |
|
|
|
spanTime.innerText = 'GIF'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!canAutoplay && !noPlayButton) { |
|
|
|
|
|
|
|
needPlayButton = true; |
|
|
|
|
|
|
|
noAutoDownload = undefined; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(needPlayButton) { |
|
|
|
|
|
|
|
spanPlay = document.createElement('span'); |
|
|
|
|
|
|
|
spanPlay.classList.add('video-play', 'tgico-largeplay', 'btn-circle', 'position-center'); |
|
|
|
|
|
|
|
container.append(spanPlay); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -237,7 +248,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
|
|
|
|
|
|
|
|
res.thumb = photoRes; |
|
|
|
res.thumb = photoRes; |
|
|
|
|
|
|
|
|
|
|
|
if(!canAutoplay || onlyPreview) { |
|
|
|
if((!canAutoplay && doc.type !== 'gif') || onlyPreview) { |
|
|
|
res.loadPromise = photoRes.loadPromises.full; |
|
|
|
res.loadPromise = photoRes.loadPromises.full; |
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
@ -370,7 +381,15 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai |
|
|
|
return; |
|
|
|
return; |
|
|
|
} */ |
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(doc.type === 'gif' && !canAutoplay) { |
|
|
|
|
|
|
|
attachClickEvent(container, (e) => { |
|
|
|
|
|
|
|
cancelEvent(e); |
|
|
|
|
|
|
|
spanPlay.remove(); |
|
|
|
|
|
|
|
load(); |
|
|
|
|
|
|
|
}, {capture: true, once: true}); |
|
|
|
|
|
|
|
} else { |
|
|
|
res.loadPromise = !lazyLoadQueue ? load().render : (lazyLoadQueue.push({div: container, load: () => load().render}), Promise.resolve()); |
|
|
|
res.loadPromise = !lazyLoadQueue ? load().render : (lazyLoadQueue.push({div: container, load: () => load().render}), Promise.resolve()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|