ademidun / atila-client-web-app

Client web app for atila.ca
https://atila.ca
0 stars 0 forks source link

Create components to record and play audio #548

Closed ademidun closed 2 years ago

ademidun commented 2 years ago

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

Logic 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 of audio type.

You will need to figure out the logic for determining how to pass the audioPath to FormDynamicInput using mentorProfileFormConfig

One idea is to create a filePath key to input configs that takes a function with the model input as an argument.

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;

Audio Play

Putting it all Together

Example Tutorials

The first link looks like all you might need, but I've included some additional options just in case: