Chapter 681: Foreign file types
Core Idea
:::warning We are phasing out Media Parser and are moving to Mediabunny!
Key Concepts
- Available errors
- IsAnImageError
- IsAPdfError
- IsAnUnsupportedFileTypeError
Code Examples
try {
await parseMedia({
src: 'https://example.com/my-video.png',
fields: {},
});
} catch (e) {
if (e instanceof IsAnImageError) {
console.log('The file is an image of format:', e.imageType, 'dimensions:', e.dimensions);
} else if (e instanceof IsAPdfError) {
console.log('The file is a PDF');
} else if (e instanceof IsAnUnsupportedFileTypeError) {
console.log('The file is of an unsupported type');
}
}
- What it demonstrates: Usage pattern for Foreign file types from the official docs.
Key Takeaways
- Understand available errors when working with Foreign file types.
- Understand isanimageerror when working with Foreign file types.
- Understand isapdferror when working with Foreign file types.
- Understand isanunsupportedfiletypeerror when working with Foreign file types.
Connects To
- Download and Parse: related page in the Media Parser (@remotion/media-parser) section.
- Download and Parse Media: related page in the Media Parser (@remotion/media-parser) section.
- Fast and Slow: related page in the Media Parser (@remotion/media-parser) section.