Skip to content

Commit ea760ac

Browse files
authored
Merge pull request #193 from Sociosarbis/feat-terminate-threads
feat(exit): #136 provide a method to exit program
2 parents ea4cf1f + 5a3b493 commit ea760ac

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/createFFmpeg.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ module.exports = (_options = {}) => {
9595
}
9696
};
9797

98-
9998
/*
10099
* Determine whether the Core is loaded.
101100
*/
@@ -171,6 +170,21 @@ module.exports = (_options = {}) => {
171170
}
172171
};
173172

173+
/**
174+
* forcibly terminate the ffmpeg program.
175+
*/
176+
const exit = () => {
177+
if (Core === null) {
178+
throw NO_LOAD;
179+
} else {
180+
running = false;
181+
Core.exit(1);
182+
Core = null;
183+
ffmpeg = null;
184+
runResolve = null;
185+
}
186+
};
187+
174188
const setProgress = (_progress) => {
175189
progress = _progress;
176190
};
@@ -191,6 +205,7 @@ module.exports = (_options = {}) => {
191205
load,
192206
isLoaded,
193207
run,
208+
exit,
194209
FS,
195210
};
196211
};

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export interface FFmpeg {
7777
setProgress(progress: ProgressCallback): void;
7878
setLogger(log: LogCallback): void;
7979
setLogging(logging: boolean): void;
80+
exit(): void;
8081
}
8182

8283
/*

0 commit comments

Comments
 (0)