Add object detection, tracking, mobile notifications, and search to any security camera.
fix sort and scrub bar
roryclear14f863b39f72
diff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex fcff020..200c40f 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -101,7 +101,9 @@// Sort .mp4 files by numeric valuesNSArray *sortedFiles = [mp4Files sortedArrayUsingComparator:^NSComparisonResult(NSString *file1, NSString *file2) {- NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\\d+)" options:0 error:nil];+ NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"_(\\d+)_"+ options:0+ error:nil];NSTextCheckingResult *match1 = [regex firstMatchInString:file1 options:0 range:NSMakeRange(0, file1.length)];NSTextCheckingResult *match2 = [regex firstMatchInString:file2 options:0 range:NSMakeRange(0, file2.length)];@@ -212,7 +214,6 @@dprintf(clientSocket, "\r\n");[self sendFileData:file toSocket:clientSocket withContentLength:fileSize];}-fclose(file);}diff --git a/player.html b/player.htmlindex cf20f84..4870658 100644--- a/player.html+++ b/player.html@@ -20,23 +20,32 @@}#controls {display: flex;+ flex-direction: column;align-items: center;margin-top: 10px;width: 100%;max-width: 640px;}+ .top-controls {+ display: flex;+ align-items: center;+ width: 100%;+ justify-content: space-between;+ }#progress {- flex: 1;- height: 5px;+ width: 100%;+ height: 10px;background-color: #ccc;- margin: 0 10px;+ margin: 10px 0;cursor: pointer;position: relative;+ border-radius: 5px;}#progress-bar {width: 0;height: 100%;background-color: #007bff;+ border-radius: 5px;}button {padding: 5px 10px;@@ -54,18 +63,20 @@<video id="videoPlayer2" playsinline style="display: none;"></video></div><div id="controls">- <button id="playPauseBtn">Play</button>+ <div class="top-controls">+ <button id="playPauseBtn">Play</button>+ <div id="timeDisplay">0:00 / 0:00</div>+ </div><div id="progress"><div id="progress-bar"></div></div>- <div id="timeDisplay">0:00 / 0:00</div></div><script>- let segments = []; // Initially empty, will be populated from the server- const segmentDuration = 60; // Duration of each segment in seconds+ let segments = [];+ const segmentDuration = 60;let totalDuration = 0;- let retryTimeout = 2000; // Retry interval in milliseconds+ let retryTimeout = 2000;const videoPlayer1 = document.getElementById('videoPlayer1');const videoPlayer2 = document.getElementById('videoPlayer2');@@ -85,20 +96,13 @@const response = await fetch('/get-segments');if (response.ok) {const newSegments = await response.json();-if (Array.isArray(newSegments)) {const oldTotalDuration = totalDuration;-- // Update segments list and total durationsegments = newSegments;totalDuration = segments.length * segmentDuration;-- // If the total duration changes, update UIif (totalDuration !== oldTotalDuration) {updateTimeline();preloadNextSegment();-- // Start playing the first segment if the list changesif (!isPlaying && segments.length > 0) {playSegment();}@@ -132,8 +136,6 @@currentVideo.src = segments[currentSegment];currentVideo.currentTime = targetTime;currentVideo.play();-- // Preload the next segment after scrubbingpreloadNextSegment();}@@ -215,13 +217,9 @@}progress.addEventListener("mousedown", startScrubbing);- document.addEventListener("mouseup", stopScrubbing);progress.addEventListener("touchstart", startScrubbing);- document.addEventListener("touchend", stopScrubbing);- setInterval(() => {- fetchSegments();- }, 3000); // Poll every 3 seconds for new segments+ setInterval(fetchSegments, 3000);videoPlayer1.addEventListener("timeupdate", updateTimeline);videoPlayer2.addEventListener("timeupdate", updateTimeline);@@ -243,7 +241,6 @@isPlaying = !isPlaying;});- // Initially fetch segments and start playingfetchSegments();</script></body>