Capítulo 56 de 988

Chapter 56: getAudioDurationInSeconds()

Core Idea

:::info Deprecated This function has been deprecated. Use getMediaMetadata() instead, which is faster and supports more formats.

Key Concepts

  • Arguments
  • src
  • Return value
  • Example
  • See also

Code Examples

const MyComp: React.FC = () => {
  const getDuration = useCallback(async () => {
    const publicFile = await getAudioDurationInSeconds(staticFile('voiceover.wav')); // 33.221
    const imported = await getAudioDurationInSeconds(music); // 127.452
    const remote = await getAudioDurationInSeconds('https://example.com/remote-audio.aac'); // 50.24
  }, []);

  useEffect(() => {
    getDuration();
  }, []);

  return null;
};
  • What it demonstrates: Usage pattern for getAudioDurationInSeconds() from the official docs.

Key Takeaways

  1. Understand arguments when working with getAudioDurationInSeconds().
  2. Understand src when working with getAudioDurationInSeconds().
  3. Understand return value when working with getAudioDurationInSeconds().
  4. Understand example when working with getAudioDurationInSeconds().
  5. Understand see also when working with getAudioDurationInSeconds().

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.