MiniAudioPlayer component renders audio streams and optional audio waveform visualization.

This component is used to display and play audio for participants who are not currently visible in the main video grid. It supports component override for the MiniAudio visualization component, allowing full customization of the audio waveform display.

The component handles:

  • Audio stream playback through RTCView
  • Audio level monitoring and decibel calculations
  • Optional waveform visualization through MiniAudio component
  • Breakout room audio filtering
  • Automatic audio level updates
const CustomWaveform = ({ stream, name, participant }) => (
<View style={{ padding: 10, backgroundColor: '#1a1a1a' }}>
<Text style={{ color: '#fff' }}>🎵 {name}</Text>
{/* Custom audio visualization logic */}
</View>
);
// Basic usage with default MiniAudio component
import { MiniAudioPlayer } from 'mediasfu-reactnative-expo';

<MiniAudioPlayer
stream={audioStream}
consumer={consumerInstance}
remoteProducerId='producer-123'
parameters={{
getUpdatedAllParams: () => params,
reUpdateInter: ({ name, add, average, parameters }) => {},
updateParticipantAudioDecibels: ({ name, averageLoudness, parameters }) => {},
breakOutRoomStarted: false,
breakOutRoomEnded: false,
limitedBreakRoom: [],
}}
/>
// With custom MiniAudio component override
import { MiniAudioPlayer } from 'mediasfu-reactnative-expo';
import { CustomAudioVisualizer } from './CustomAudioVisualizer';

<MiniAudioPlayer
stream={audioStream}
consumer={consumerInstance}
remoteProducerId='producer-123'
parameters={{
getUpdatedAllParams: () => params,
reUpdateInter: ({ name, add, average, parameters }) => {},
updateParticipantAudioDecibels: ({ name, averageLoudness, parameters }) => {},
breakOutRoomStarted: false,
breakOutRoomEnded: false,
limitedBreakRoom: [],
}}
MiniAudioComponent={CustomAudioVisualizer}
miniAudioProps={{
showName: true,
waveColor: '#00ff00',
backgroundColor: '#000000'
}}
/>
// Using component override from parameters (typical in MediaSFU components)
import { MediasfuGeneric } from 'mediasfu-reactnative-expo';
import { MyCustomMiniAudio } from './components/MyCustomMiniAudio';

<MediasfuGeneric
credentials={credentials}
// MiniAudioPlayer will automatically use this component override
miniAudioComponent={MyCustomMiniAudio}
/>
// Advanced: Custom audio visualizer with waveform animation
import React from 'react';
import { View, Text, Animated, StyleSheet } from 'react-native';

const AnimatedAudioVisualizer = ({ stream, name, participant }) => {
const [audioLevel, setAudioLevel] = React.useState(0);

// Monitor audio level from stream
React.useEffect(() => {
// Audio level monitoring logic here
}, [stream]);

return (
<View style={styles.container}>
<Text style={styles.name}>{name}</Text>
<View style={styles.waveformContainer}>
{[1, 2, 3, 4, 5].map(i => (
<Animated.View
key={i}
style={[
styles.waveBar,
{ height: audioLevel * 40 * Math.random() }
]}
/>
))}
</View>
</View>
);
};

<MiniAudioPlayer
stream={audioStream}
consumer={consumerInstance}
remoteProducerId='producer-456'
parameters={parameters}
MiniAudioComponent={AnimatedAudioVisualizer}
/>

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'