mediaParserController()
将 mediaParserController() 传递给 controller 以控制 parseMedia() 函数。
🌐 Pass mediaParserController() to controller to steer the parseMedia() function.
每个 mediaParserController 只能附加到 1 个 parseMedia() 调用。
🌐 Each mediaParserController can only be attached to 1 parseMedia() call.
Use mediaParserController()import {mediaParserController ,parseMedia } from '@remotion/media-parser'; constcontroller =mediaParserController ();parseMedia ({src : 'https://www.w3schools.com/html/mov_bbb.mp4',controller , }); // Pausecontroller .pause (); // Resumecontroller .resume (); // Abortcontroller .abort ();
应用编程接口
🌐 API
此函数返回一个可以传递给 parseMedia({controller}) 的对象。
🌐 This function returns an object that can be passed to parseMedia({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.
seek(timeInSeconds: number)
getSeekingHints()
返回一个解析为 seeking hints 的 Promise。
🌐 Returns a promise that resolves to the seeking hints.
addEventListener()
请参见下方的活动。
🌐 See events below.
removeEventListener()
请参见下方的活动。
🌐 See events below.
事件
🌐 Events
你可以将事件监听器附加到 mediaParserController() 返回的对象上。
🌐 You can attach event listeners to the object returned by mediaParserController().
Use eventsimport {mediaParserController ,parseMedia } from '@remotion/media-parser'; constcontroller =mediaParserController (); constonPause = () => {console .log ('Paused'); }; constonResume = () => {console .log ('Resumed'); };controller .addEventListener ('pause',onPause );controller .addEventListener ('resume',onResume ); // Make sure to cleanup later:controller .removeEventListener ('pause',onPause );controller .removeEventListener ('resume',onResume );
它还会触发以下事件:
🌐 It also 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