photo: add delay to live playback

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/900/head
Varun Patil 2023-10-30 01:26:06 -07:00
parent 1e5a5d3b4f
commit 543646624a
1 changed files with 19 additions and 9 deletions

View File

@ -119,6 +119,7 @@ export default defineComponent({
data: () => ({ data: () => ({
touchTimer: 0, touchTimer: 0,
playLiveTimer: 0,
faceSrc: null as string | null, faceSrc: null as string | null,
}), }),
@ -144,6 +145,7 @@ export default defineComponent({
/** Clear timers */ /** Clear timers */
beforeDestroy() { beforeDestroy() {
clearTimeout(this.touchTimer); clearTimeout(this.touchTimer);
clearTimeout(this.playLiveTimer);
// Clean up blob url if face rect was created // Clean up blob url if face rect was created
if (this.faceSrc) { if (this.faceSrc) {
@ -269,7 +271,11 @@ export default defineComponent({
}, },
/** Start preview video */ /** Start preview video */
async playVideo() { playVideo() {
utils.setRenewingTimeout(
this,
'playLiveTimer',
async () => {
const video = this.refs.video; const video = this.refs.video;
if (!video || this.data.flag & this.c.FLAG_SELECTED) return; if (!video || this.data.flag & this.c.FLAG_SELECTED) return;
@ -280,9 +286,13 @@ export default defineComponent({
// ignore, pause was probably called too soon // ignore, pause was probably called too soon
} }
}, },
400,
);
},
/** Stop preview video */ /** Stop preview video */
stopVideo() { stopVideo() {
window.clearTimeout(this.playLiveTimer);
this.refs.video?.pause(); this.refs.video?.pause();
}, },
}, },