1515import java .util .Arrays ;
1616import java .util .List ;
1717
18- import io .reactivex .Observable ;
19- import io .reactivex .schedulers .Schedulers ;
20-
2118/**
2219 * <pre>
2320 * author : VeiZhang
@@ -35,7 +32,6 @@ public class FFmpeg {
3532 private static FFmpeg mInstance = null ;
3633
3734 private Context mContext = null ;
38- private String mFfmpeg = "" ;
3935
4036 public static void init (Context context ) {
4137 init (context , null );
@@ -57,7 +53,7 @@ public static void init(Context context, boolean initialized, CommanderOptions o
5753 }
5854 mInstance = new FFmpeg (context .getApplicationContext ());
5955 if (initialized ) {
60- mInstance .initFFmpeg (). subscribe () ;
56+ mInstance .initFFmpeg ();
6157 }
6258 }
6359
@@ -69,21 +65,17 @@ private FFmpeg(Context context) {
6965 * 默认初始化,每次启动应用时,删除旧的ffmpeg文件
7066 * @return
7167 */
72- public Observable < String > initFFmpeg () {
68+ public void initFFmpeg () {
7369 File ffmpegFile = new File (mInstance .mContext .getFilesDir (), FFMPEG );
7470
75- return Observable .just (ffmpegFile ).subscribeOn (Schedulers .io ())
76- .map (file -> {
77- /**
78- * ffmpeg文件有更新,无法判断,因此每次都更新
79- */
80- if (ffmpegFile .exists ()) {
81- boolean success = ffmpegFile .delete ();
82- Log .e (TAG , "checkFFmpeg: delete old ffmpeg file success:" + success );
83- }
84- mFfmpeg = checkFFmpeg ();
85- return mFfmpeg ;
86- });
71+ /**
72+ * ffmpeg文件有更新,无法判断,因此每次都更新
73+ */
74+ if (ffmpegFile .exists ()) {
75+ boolean success = ffmpegFile .delete ();
76+ Log .e (TAG , "checkFFmpeg: delete old ffmpeg file success:" + success );
77+ }
78+ checkFFmpeg ();
8779 }
8880
8981 /**
@@ -95,9 +87,10 @@ public Observable<String> initFFmpeg() {
9587 */
9688 @ Deprecated
9789 public static CommandTask addTask (@ NonNull List <String > command , IListener listener ) {
90+ String ffmpeg = checkFFmpeg ();
9891 List <String > cmd = new ArrayList <>(command );
99- if (!command .contains (mInstance . mFfmpeg )) {
100- cmd .add (0 , mInstance . mFfmpeg );
92+ if (!command .contains (ffmpeg )) {
93+ cmd .add (0 , ffmpeg );
10194 }
10295 return Commander .addTask (cmd , listener );
10396 }
0 commit comments