Skip to content

Commit

Permalink
Minor cleanup and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-nexus committed Jul 14, 2024
1 parent 0b3b9a1 commit d9c0407
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
28 changes: 14 additions & 14 deletions src/components/Player/BackgroundMusicThroughVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ export default function BackgroundMusicThroughVideo() {
}, [playerState, bgMusicVol])

// TODO: Implement video play pause handling with ref forwarding
useEffect(() => {
videoRef.current.addEventListener("pause", handleVideoPlayPause)

return (() => {
try {
videoRef.current.removeEventListener("pause", handleVideoPlayPause)
} catch (error) {
console.log(error)
}
})
}, [])

function handleVideoPlayPause() {
}
// useEffect(() => {
// videoRef.current.addEventListener("pause", handleVideoPlayPause)

// return (() => {
// try {
// videoRef.current.removeEventListener("pause", handleVideoPlayPause)
// } catch (error) {
// console.log(error)
// }
// })
// }, [])

// function handleVideoPlayPause() {
// }

return (
// Fixed position tiny invisible video
Expand Down
5 changes: 2 additions & 3 deletions src/components/Player/PlayerControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ export default function PlayerControls() {
// Ref value is used to determine, what to do next
function speechCompleteCallback() {
console.log("Speech has ended")
if (speechEndReasonRef.current === "pause") {
setPlayerState("paused")
}
if (speechEndReasonRef.current === "forward") {
setSpeakingSentenceIndex((speakingSentenceIndex + 1))
}
Expand Down Expand Up @@ -162,6 +159,7 @@ export default function PlayerControls() {
setIsPlayerOpen(false)

// Using button click, since calling rewind(), playPause(), forward() functions mess up the state unpredictably. TODO: Need to figure out why this happens.
// Button click also causes issues if the element is currently focussed.
if (event.key === "ArrowLeft")
rewindButton.current.click()

Expand Down Expand Up @@ -189,6 +187,7 @@ export default function PlayerControls() {
if (playerState === "playing") {
speechSynthesis.cancel()
speechEndReasonRef.current = "pause"
setPlayerState("paused")
}
if (playerState === "paused") {
setPlayerState("playing")
Expand Down
2 changes: 1 addition & 1 deletion src/constants/appConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For best listening experience, here are some recommendations. On desktop devices
If you like Listen, you can install it as an app on your phone or desktop. Even more, you can quickly integrate it on your blog or webpages, so that your readers can instantly listen to your pages.
Okay bye bye!`
export const CORS_ERROR_MESSAGE = `[LISTEN]: To fetch the article, make sure to allow cross origin requests (CORS) on your server from https://www.vivek.nexus. See https://github.com/vivek-nexus/listen/blob/main/README.md#passing-a-link-to-fetch.`
export const CORS_ERROR_MESSAGE = `[LISTEN]: To fetch the article, make sure to allow cross origin requests (CORS) on your server from https://www.vivek.nexus. See https://github.com/vivek-nexus/listen?tab=readme-ov-file#listen.`
export const PROXY_SERVER_URL = "https://render-express-server-q222.onrender.com"
export const SpeechSettingDefaultValues = {
rate: 10,
Expand Down

0 comments on commit d9c0407

Please sign in to comment.