Open MathiSans opened 8 months ago
As a user I want to hear athmospheric and calming sound, so I can have an emersive experience while reflecting my mood
focus page
toggle sound
button is prominent
audio fades out
Preparations:
file-loader
next.config.js
look for mp3 files
create folders
flow.js:
audioPlaying
FlowContainer
PlaySound
> 0
audioPlaying, page
src
PlayButton
1
hanndleIsPlaying
PlaySound.js:
PlaySound.js
useRef, useEffect, useState
src, play, pageIndex
useRef
null
useState
currentVolume
0.5
useEffect
<audio>
play()
ref,
and
pageIndex, currentVolume, setCurrentVolume
DecreaseVolume.js:
DecreaseVolume
if pageIndex > 1
setInterval
if currentVolume > 0
-1
50ms
clearInterval
PlayButton.js:
styled, Image, playing
handleIsPlaying, audioPlaying
<StyledPlayButton>
handleIsPlaying
onClick
true
<p>
style
Amazing! I am super happy you found this out all by yourself! (Sorry for not helping more, I was distracted with reviews) But very very nice job! Supert excited to see this implemented 🤩
Value proposition
As a user I want to hear athmospheric and calming sound, so I can have an emersive experience while reflecting my mood
Description
Acceptance criteria
focus page
toggle sound
on and offbutton is prominent
on the pageaudio fades out
when the user proceeds in the multi-step formTasks
Preparations:
file-loader
to process mp3 filesnext.config.js
to include the loaderlook for mp3 files
in the project directorycreate folders
for images and sound files in the public folderflow.js:
audioPlaying
useStateFlowContainer
component to mountPlaySound
for when the page index is> 0
audioPlaying, page
to PlaySound and imagesrc
for audio filePlayButton
when the page index equals1
hanndleIsPlaying
and stateaudioPlaying
to PlayButtonPlaySound.js:
PlaySound.js
inside an euqally named folder and add it to components folderuseRef, useEffect, useState
PlaySound
and pass propssrc, play, pageIndex
useRef
variable and set initial state tonull
useState
variable forcurrentVolume
with inital state of0.5
useEffect
:audioPlaying
is true anduseRef
variable is notnull
->currentVolume
sets volume for<audio>
->play()
function to start playing the audio file<audio>
withref,
srcand
loop`pageIndex, currentVolume, setCurrentVolume
DecreaseVolume.js:
useEffect
DecreaseVolume
and pass propspageIndex, currentVolume, setCurrentVolume
useEffect
:if pageIndex > 1
startsetInterval
if currentVolume > 0
decrease Volume by-1
every50ms
clearInterval
pageIndex, currentVolume, setCurrentVolume
to dependency arrayPlayButton.js:
styled, Image, playing
PlayButton
, pass propshandleIsPlaying, audioPlaying
<StyledPlayButton>
handleIsPlaying
withonClick
->audioPlaying
true
mount/display<p>
with "turn sound on"style
the button and p tag