Function AudioCard

AudioCard component displays an audio card with various controls, participant information, and a visual waveform.

This component renders an interactive card with customizable styles, an image, and control buttons for audio and video functionality. The waveform reacts to audio levels, and the component manages real-time states through parameters like audioDecibels, participant information, and coHost responsibilities.

import React from 'react';
import { AudioCard } from 'mediasfu-reactjs';

function App() {
const participant = { name: "John Doe", id: "123", muted: false, videoOn: true };
const parameters = {
audioDecibels: [{ name: "John Doe", averageLoudness: 128 }],
participants: [participant],
socket: {}, // Add actual socket instance here
coHostResponsibility: [],
roomName: "Main Room",
coHost: "Host123",
islevel: "1",
member: "member",
eventType: "meeting",
getUpdatedAllParams: () => parameters,
};

return (
<AudioCard
name="John Doe"
participant={participant}
parameters={parameters}
audioDecibels={parameters.audioDecibels[0]}
showControls={true}
showInfo={true}
controlsPosition="topLeft"
infoPosition="topRight"
backgroundColor="black"
barColor="red"
textColor="white"
imageSource="https://example.com/image.jpg"
roundedImage={true}
imageStyle={{ width: "100px", height: "100px" }}
customStyle={{ width: "200px", height: "200px" }}
controlUserMedia={() => console.log("Control media invoked")}
videoInfoComponent={<CustomVideoInfoComponent />}
videoControlsComponent={<CustomVideoControlsComponent />}
/>
);
}

export default App;

Properties

propTypes?: WeakValidationMap<AudioCardOptions>

Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.

We recommend using TypeScript instead of checking prop types at runtime.

contextTypes?: ValidationMap<any>

Lets you specify which legacy context is consumed by this component.

defaultProps?: Partial<AudioCardOptions>

Used to define default values for the props accepted by the component.

type Props = { name?: string }

const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}

MyComponent.defaultProps = {
name: 'John Doe'
}
displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.


const MyComponent: FC = () => {
return <div>Hello!</div>
}

MyComponent.displayName = 'MyAwesomeComponent'