Function MiniAudioPlayer

MiniAudioPlayer component is a React functional component that renders an audio player and optionally a mini audio component for visualizing audio waveforms.

// Import and use MiniAudioPlayer in a React component
import { MiniAudioPlayer } from 'mediasfu-reactjs';

const WaveformVisualizer = ({ stream }: { stream: MediaStream }) => (
<canvas width="300" height="50" />
);

const App = () => {
const stream = useMediaStream(); // Custom hook to get MediaStream
const parameters = {
// Mocked parameters with required functions
getUpdatedAllParams: () => updatedParameters,
reUpdateInter: () => {},
updateParticipantAudioDecibels: () => {},
breakOutRoomStarted: false,
breakOutRoomEnded: false,
limitedBreakRoom: [],
};

return (
<MiniAudioPlayer
stream={stream}
consumer={consumer}
remoteProducerId="producer123"
parameters={parameters}
MiniAudioComponent={WaveformVisualizer}
miniAudioProps={{ color: 'blue' }}
/>
);
};

Properties

propTypes?: WeakValidationMap<MiniAudioPlayerOptions>

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<MiniAudioPlayerOptions>

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'