Add classWorkerURL (#652)
This commit is contained in:
parent
29e523bcff
commit
ce375d99a8
@ -184,13 +184,19 @@ export class FFmpeg {
|
||||
* @returns `true` if ffmpeg core is loaded for the first time.
|
||||
*/
|
||||
public load = (
|
||||
config: FFMessageLoadConfig = {},
|
||||
{ classWorkerURL, ...config }: FFMessageLoadConfig = {},
|
||||
{ signal }: FFMessageOptions = {}
|
||||
): Promise<IsFirst> => {
|
||||
if (!this.#worker) {
|
||||
this.#worker = new Worker(new URL("./worker.js", import.meta.url), {
|
||||
type: "module",
|
||||
});
|
||||
this.#worker = classWorkerURL ?
|
||||
new Worker(new URL(classWorkerURL, import.meta.url), {
|
||||
type: "module",
|
||||
}) :
|
||||
// We need to duplicated the code here to enable webpack
|
||||
// to bundle worekr.js here.
|
||||
new Worker(new URL("./worker.js", import.meta.url), {
|
||||
type: "module",
|
||||
});
|
||||
this.#registerHandlers();
|
||||
}
|
||||
return this.#send(
|
||||
|
@ -17,11 +17,19 @@ export interface FFMessageLoadConfig {
|
||||
*/
|
||||
wasmURL?: string;
|
||||
/**
|
||||
* `ffmpeg-core.worker.js` URL.
|
||||
* `ffmpeg-core.worker.js` URL. This worker is spawned when using multithread version of ffmpeg-core.
|
||||
*
|
||||
* @ref: https://ffmpegwasm.netlify.app/docs/overview#architecture
|
||||
* @defaultValue `https://unpkg.com/@ffmpeg/core-mt@${CORE_VERSION}/dist/umd/ffmpeg-core.worker.js`;
|
||||
*/
|
||||
workerURL?: string;
|
||||
/**
|
||||
* `ffmpeg.worker.js` URL. This worker is spawned when FFmpeg.load() is called, it is an essential worker and usually you don't need to update this config.
|
||||
*
|
||||
* @ref: https://ffmpegwasm.netlify.app/docs/overview#architecture
|
||||
* @defaultValue `./worker.js`
|
||||
*/
|
||||
classWorkerURL?: string;
|
||||
}
|
||||
|
||||
export interface FFMessageExecData {
|
||||
|
Loading…
Reference in New Issue
Block a user