11<script setup lang="ts">
2- import { computed } from ' vue' ;
2+ import { computed , reactive , ref , onBeforeUnmount } from ' vue' ;
33import { useRouter } from ' vue-router' ;
44import { useStreamStore } from ' @/stores/stream' ;
55
@@ -14,6 +14,38 @@ const props = defineProps<{
1414}>();
1515
1616const recording = computed (() => streamStore .recordings .find (r => r .id === props .recording ));
17+
18+ const recordingDuration = computed (() => {
19+ if (! recording .value ) {
20+ return 0 ;
21+ }
22+ return Math .round (((new Date (recording .value .end )).getTime () - (new Date (recording .value .start )).getTime ()) / 1000 )
23+ });
24+
25+ const data = reactive ({
26+ sliderPos: 0 ,
27+ sliderPosInterval: null as ReturnType <typeof setInterval >| null ,
28+ });
29+
30+ const video = ref <HTMLVideoElement | null >(null );
31+
32+ const setVideoPos = () => {
33+ if (! video .value ) {
34+ return ;
35+ }
36+ video .value .currentTime = data .sliderPos ;
37+ };
38+
39+ data .sliderPosInterval = setInterval (() => {
40+ if (video .value ) {
41+ data .sliderPos = video .value .currentTime ;
42+ }
43+ }, 100 );
44+ onBeforeUnmount (() => {
45+ if (data .sliderPosInterval !== null ) {
46+ clearInterval (data .sliderPosInterval );
47+ }
48+ });
1749 </script >
1850
1951<template >
@@ -34,6 +66,7 @@ const recording = computed(() => streamStore.recordings.find(r => r.id === props
3466 muted
3567 controls
3668 autoplay
69+ ref =" video"
3770 />
3871 </div >
3972 </div >
@@ -62,6 +95,13 @@ const recording = computed(() => streamStore.recordings.find(r => r.id === props
6295 </button>
6396 </div>
6497 </div> -->
98+
99+ <div v-if =" recording && recording.performed_motion_detect" class =" bg-gray-800 text-white p-4" >
100+ <input class =" range" type =" range" list =" range" step =" any" :min =" 0" :max =" recordingDuration" v-model =" data.sliderPos" @input =" setVideoPos" />
101+ <datalist id =" range" >
102+ <option v-for =" m in recording.motion" :value =" m.t" :label =" `${m.s}`" ></option >
103+ </datalist >
104+ </div >
65105
66106 <div v-if =" recording" class =" bg-gray-900 text-white p-4" >
67107 <div class =" flex items-center justify-between" >
@@ -98,4 +138,10 @@ const recording = computed(() => streamStore.recordings.find(r => r.id === props
98138 </div >
99139 </div >
100140 </div >
101- </template >
141+ </template >
142+
143+ <style scoped>
144+ .range {
145+ width : 100% ;
146+ }
147+ </style >
0 commit comments