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
- Understand arguments when working with getAudioDurationInSeconds().
- Understand src when working with getAudioDurationInSeconds().
- Understand return value when working with getAudioDurationInSeconds().
- Understand example when working with getAudioDurationInSeconds().
- 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.