-
Notifications
You must be signed in to change notification settings - Fork 5
Added looping feature to cache videos #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,11 +17,14 @@ <h3>Cache Storage</h3> | |
| <div id="listOfVideosContainer" > | ||
| </div> | ||
| <script> | ||
| let holdTimer; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [CRITICAL] The |
||
| document.getElementById('go_back_btn').addEventListener('click', () => { | ||
| let url = window.location.href | ||
| window.location.href = window.location.href.substring(0, url.lastIndexOf('/') ) | ||
|
|
||
| }); | ||
|
|
||
| async function togglePlayVideo(e, video, isLooping) { | ||
| let debugUrl = new URL("debug", window.location.href) | ||
| async function togglePlayVideo(e, video) { | ||
| try { | ||
|
|
@@ -33,13 +36,18 @@ <h3>Cache Storage</h3> | |
| url.searchParams.append("file_path", file_path) | ||
| url.searchParams.append("title", title) | ||
| url.searchParams.append("thumbnail", thumbnail) | ||
| //repeats the video if looping | ||
| if (isLooping) { | ||
| url.searchParams.append("loop", "true"); | ||
| } | ||
| console.log("Fetching URL:", url.href); | ||
| const response = await fetch(url.href, { method: "POST" }); | ||
| return response.json() | ||
| } catch(error) { | ||
| console.log(error) | ||
| } | ||
| } | ||
|
|
||
| } | ||
| async function togglePlayEntireDirectory(e) { | ||
| try { | ||
| e.preventDefault() | ||
|
|
@@ -69,17 +77,32 @@ <h3>Cache Storage</h3> | |
| } | ||
| } | ||
|
|
||
| async function handlePlayButton(e, video) { | ||
| async function handlePlayButton(e, video, isLooping) { | ||
| const playButton = document.getElementById(video.id) | ||
| const response = await togglePlayVideo(e, video) | ||
| if (playButton.classList.contains('is-looping') && isLooping) { | ||
| let stopURL = new URL(window.location.href.replace('cache', 'stop')); | ||
| await fetch(stopURL.href, { method: "POST" }); | ||
| playButton.textContent = "Stopped"; | ||
| playButton.style.backgroundColor = ""; | ||
| playButton.classList.remove('is-looping'); | ||
| isLooping = false; | ||
| setTimeout(() => { playButton.textContent = "play"; }, 2000); | ||
| return; | ||
| } | ||
| const response = await togglePlayVideo(e, video, isLooping) | ||
| if (response["detail"] === "Success") { | ||
| playButton.textContent = "Success!"; | ||
| playButton.disabled = true; | ||
|
|
||
| setTimeout(() => { | ||
| if (isLooping) { | ||
| playButton.textContent = "Looping!"; | ||
| playButton.style.backgroundColor = "green"; | ||
| playButton.classList.add('is-looping'); | ||
| } else { | ||
| playButton.textContent = "Success!"; | ||
| playButton.disabled = true; | ||
| setTimeout(() => { | ||
| playButton.textContent = "Play"; | ||
| playButton.disabled = false; | ||
| }, 2000); | ||
| } | ||
| } else { | ||
| alert(response["detail"]); | ||
| } | ||
|
|
@@ -139,10 +162,33 @@ <h3>Cache Storage</h3> | |
| playButton.textContent = 'play'; | ||
| videoSize.textContent = formatBytes(element.size_bytes); | ||
|
|
||
| playButton.addEventListener('click', (e) => { | ||
| handlePlayButton(e, element) | ||
| //Loops video if held for 750ms | ||
| playButton.addEventListener('mousedown', (e)=> { | ||
| startTime = Date.now(); | ||
| holdTimer = setTimeout(() => { | ||
| if (playButton.classList.contains('is-looping')) { | ||
| playButton.textContent = "Release to STOP"; | ||
| } else { | ||
| playButton.textContent = "Release to LOOP"; | ||
| } | ||
| }, 750); | ||
| }); | ||
|
|
||
| playButton.addEventListener('mouseup', (e) => { | ||
| clearTimeout(holdTimer); | ||
| const duration = Date.now() - startTime; | ||
|
|
||
| if (duration >= 750) { | ||
| // It was a long press | ||
| handlePlayButton(e, element, true); | ||
| } else if (!playButton.classList.contains('is-looping')){ | ||
| // It was a normal click - reset text if it started changing | ||
| playButton.textContent = "play"; | ||
| playButton.style.backgroundColor = ""; | ||
| handlePlayButton(e, element, false); | ||
| } | ||
| }); | ||
|
|
||
| playEntireDirectoryBtn.addEventListener('click', handlePlayEntireDirectoryButton); | ||
|
|
||
| videoImgContainer.appendChild(videoImg); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[CRITICAL] The change from
signal.SIGKILLtosignal.SIGILLinkill_child_processesis incorrect.SIGILL(Illegal Instruction) is not intended for process termination and can be caught or ignored by a process, potentially preventing it from being killed.SIGKILLis the appropriate signal for forceful, unblockable termination.