Closed ademidun closed 2 years ago
Create a component that can record and play audio
This component should support the following features: Start recording, stop recording, delete recording, save recording
audioPath
onAudioSaved
url
Can be found here: https://github.com/ademidun/atila-client-web-app/blob/8c75759ab2e2d42e10e33f32ede94b2890cde261/src/components/Form/FileInput.js#L17-L18
This component will be used by adding a new question type to mentorProfileFormConfig of audio type.
mentorProfileFormConfig
audio
You will need to figure out the logic for determining how to pass the audioPath to FormDynamicInput using mentorProfileFormConfig
FormDynamicInput
One idea is to create a filePath key to input configs that takes a function with the model input as an argument.
filePath
currentdate= "2022-09-26-16-32-05-55" // use Date(); USe format: YYYY-MM-DD-HH-mm-ss export const mentorProfileFormConfig = [ { keyName: 'bio_recording_url', type: 'audio', placeholder: 'Tell mentees about yourself using a voice note', html: () => (<label htmlFor="bio"> Tell mentees about yourself using a voice note </label>), filepath: (mentor) =>`mentorship/mentor/${mentor.id}/bio_recording_${currentdate}.mp3`, }, },
Use it in FormDynamicInput
case 'audio': inputForm = ( <div> {!hideLabel && <label htmlFor={keyName} className="mr-3"> {placeholder} </label> } <AudioRecord audioPath={keyName} onAudioSaved={onUpdateForm} /> </div> ); break;
audioUrl
AudioRecord
The first link looks like all you might need, but I've included some additional options just in case:
Create a component that can record and play audio
Audio Record
This component should support the following features: Start recording, stop recording, delete recording, save recording
audioPath
locationaudioPath
andonAudioSaved
onAudioSaved
is a function that returns an object. One of the keys in that object isurl
which contains the URL of the MP3 file in S3Logic for uploading to Firebase
Can be found here: https://github.com/ademidun/atila-client-web-app/blob/8c75759ab2e2d42e10e33f32ede94b2890cde261/src/components/Form/FileInput.js#L17-L18
Example
This component will be used by adding a new question type to
mentorProfileFormConfig
ofaudio
type.You will need to figure out the logic for determining how to pass the
audioPath
toFormDynamicInput
usingmentorProfileFormConfig
One idea is to create a
filePath
key to input configs that takes a function with the model input as an argument.Use it in FormDynamicInput
Audio Play
audioUrl
which is the link to an MP3 file.Putting it all Together
AudioRecord
component to theFormDynamicInput
component as anaudio
typeaudio
to mentorProfileFormConfigExample Tutorials
The first link looks like all you might need, but I've included some additional options just in case: