Pause, resume and abort parsing
You can pause, resume and abort the parsing process.
Create a mediaParserController() and use the following methods:
Pause and resume
Pause and resumetsximport {mediaParserController ,parseMedia } from '@remotion/media-parser';constcontroller =mediaParserController ();parseMedia ({src : 'https://www.w3schools.com/html/mov_bbb.mp4',controller ,}).then (() => {console .log ('Finished downloading');}).catch ((err ) => {console .error ('Error downloading',err );});// Wait 1 sec, pause, wait 1 sec, resumeawait newPromise ((resolve ) =>setTimeout (resolve , 1000));controller .pause ();await newPromise ((resolve ) =>setTimeout (resolve , 1000));controller .resume ();
Cancel a parsing process
Cancel a parsing processtsximport {mediaParserController ,parseMedia } from '@remotion/media-parser';constcontroller =mediaParserController ();parseMedia ({src : 'https://www.w3schools.com/html/mov_bbb.mp4',controller ,}).then (() => {console .log ('Finished parsing');}).catch ((err ) => {console .error ('Error parsing',err );});// Cancel after 10 secondsawait newPromise ((resolve ) =>setTimeout (resolve , 10_000));controller .abort ();
Checking if a parse was aborted
Use the hasBeenAborted() function to check if a parse was aborted using the .abort() method.
Checking if a parse was abortedtsximport {mediaParserController ,parseMedia ,hasBeenAborted } from '@remotion/media-parser';constcontroller =mediaParserController ();constpromise =parseMedia ({src : 'https://www.w3schools.com/html/mov_bbb.mp4',controller ,}).then (() => {console .log ('Finished downloading');}).catch ((err ) => {if (hasBeenAborted (err )) {console .log ('Download was cancelled');} else {console .error ('Error downloading',err );}});