Chapter 73: useAudioData()
Core Idea
_Part of the @remotion/media-utils package of helper functions.
Key Concepts
- Arguments
- src
- options?<AvailableFrom v="4.0.458"/>
- sampleRate?<AvailableFrom v="4.0.458"/>
- requestInit?<AvailableFrom v="4.0.458"/>
- Return value
- Example
- Errors
Code Examples
export const MyComponent: React.FC = () => {
const audioData = useAudioData('https://example.com/authenticated-audio.mp3', {
requestInit: {
credentials: 'include',
},
});
if (!audioData) {
return null;
}
return <div>This file has a {audioData.sampleRate} sampleRate.</div>;
};
- What it demonstrates: Usage pattern for useAudioData() from the official docs.
Key Takeaways
- Understand arguments when working with useAudioData().
- Understand src when working with useAudioData().
- Understand options?<availablefrom v="4.0.458"/> when working with useAudioData().
- Understand samplerate?<availablefrom v="4.0.458"/> when working with useAudioData().
- Understand requestinit?<availablefrom v="4.0.458"/> when working with useAudioData().
Connects To
- Cancel Render: related page in the Hooks & Data APIs section.
- Continue Render: related page in the Hooks & Data APIs section.
- Data Fetching: related page in the Hooks & Data APIs section.