Skip to content

Commit 3f8b8b6

Browse files
committed
small improvements
1 parent 910d04d commit 3f8b8b6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lightly_studio_view/src/lib/components/VideoItem/VideoItem.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
let frames = $state<FrameView[]>(video.frame == null ? [] : [video.frame]);
2222
2323
async function handleMouseEnter() {
24-
await loadFrames(0);
24+
await loadFrames(1);
2525
if (videoEl) {
2626
// Check if the video has enough data
2727
if (videoEl.readyState < 2) {
@@ -55,7 +55,7 @@
5555
}
5656
5757
async function loadFrames(cursor: number) {
58-
let framesWithAnnotations = await getAllFrames({
58+
let videoFrames = await getAllFrames({
5959
path: {
6060
video_frame_dataset_id: (video.frame?.sample as SampleView).dataset_id
6161
},
@@ -65,7 +65,8 @@
6565
limit: 25
6666
}
6767
});
68-
frames = [...frames, ...(framesWithAnnotations?.data?.data ?? [])];
68+
69+
frames = [...frames, ...(videoFrames?.data?.data ?? [])];
6970
}
7071
</script>
7172

lightly_studio_view/src/routes/datasets/[dataset_id]/videos/[sample_id]/+page.svelte

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
let containerEl: HTMLDivElement | null = null;
2525
let overlaySize = $state(0);
2626
let overlayHeight = $state(0);
27+
let currentIndex = 0;
2728
2829
$effect(() => {
2930
if (containerEl) {
@@ -34,7 +35,7 @@
3435
3536
function onUpdate(frame: FrameView | VideoFrameView | null, index: number | null) {
3637
currentFrame = frame;
37-
if (index != null && index % 25 == 0 && index != 0) {
38+
if (index != null && index % 25 == 0 && index != 0 && currentIndex < index) {
3839
loadFrames(index);
3940
}
4041
}
@@ -54,7 +55,7 @@
5455
}
5556
5657
function onPlay() {
57-
loadFrames(0);
58+
loadFrames(1);
5859
}
5960
</script>
6061

@@ -98,19 +99,19 @@
9899
<div class="min-w-full space-y-3 text-diffuse-foreground">
99100
<div class="flex items-start gap-3">
100101
<span class="truncate text-sm font-medium" title="Width">Width:</span>
101-
<span class="text-sm">{sample.width}px</span>
102+
<span class="text-sm">{sample?.width}px</span>
102103
</div>
103104
<div class="flex items-start gap-3">
104105
<span class="truncate text-sm font-medium" title="Height">Height:</span>
105-
<span class="text-sm">{sample.height}px</span>
106+
<span class="text-sm">{sample?.height}px</span>
106107
</div>
107108
<div class="flex items-start gap-3">
108109
<span class="truncate text-sm font-medium" title="Duration">Duration:</span>
109-
<span class="text-sm">{sample.duration_s.toFixed(2)} seconds</span>
110+
<span class="text-sm">{sample?.duration_s?.toFixed(2)} seconds</span>
110111
</div>
111112
<div class="flex items-start gap-3">
112113
<span class="truncate text-sm font-medium" title="FPS">FPS:</span>
113-
<span class="text-sm">{sample.fps.toFixed(2)}</span>
114+
<span class="text-sm">{sample?.fps.toFixed(2)}</span>
114115
</div>
115116
</div>
116117
</Segment>

0 commit comments

Comments
 (0)