Capítulo 73 de 988

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

  1. Understand arguments when working with useAudioData().
  2. Understand src when working with useAudioData().
  3. Understand options?<availablefrom v="4.0.458"/> when working with useAudioData().
  4. Understand samplerate?<availablefrom v="4.0.458"/> when working with useAudioData().
  5. 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.