Skip to main content

mediaParserController()

Pass mediaParserController() to controller to steer the parseMedia() function.

Each mediaParserController can only be attached to 1 parseMedia() call.

Use mediaParserController()
tsx
import {mediaParserController, parseMedia} from '@remotion/media-parser';
 
const controller = mediaParserController();
 
parseMedia({
src: 'https://www.w3schools.com/html/mov_bbb.mp4',
controller,
});
 
// Pause
controller.pause();
 
// Resume
controller.resume();
 
// Abort
controller.abort();

API

This function returns an object that can be passed to parseMedia({controller}) and downloadAndParseMedia({controller}).

It has the following methods:

pause()

Pauses the download and parsing process.

resume()

Resumes the download and parsing process.

abort()

Aborts the download and parsing process.

getSeekingHints()

Returns a promise that resolves to the seeking hints.

addEventListener()

See events below.

removeEventListener()

See events below.

Events

You can attach event listeners to the mediaParserController object.

Use events
tsx
import {mediaParserController, parseMedia} from '@remotion/media-parser';
 
const controller = mediaParserController();
 
const onPause = () => {
console.log('Paused');
};
 
const onResume = () => {
console.log('Resumed');
};
 
controller.addEventListener('pause', onPause);
controller.addEventListener('resume', onResume);
 
// Make sure to cleanup later:
controller.removeEventListener('pause', onPause);
controller.removeEventListener('resume', onResume);

The mediaParserController object emits the following events:

pause

Emitted when the download and parsing process is paused.

resume

Emitted when the download and parsing process is resumed.

See also