Jelajahi Sumber

优化代码

hwh97 6 tahun lalu
induk
melakukan
d6e143319f

+ 20 - 20
.idea/libraries/Dart_SDK.xml

@@ -1,26 +1,26 @@
 <component name="libraryTable">
   <library name="Dart SDK">
     <CLASSES>
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/async" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/cli" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/collection" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/convert" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/core" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/developer" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/ffi" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/html" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/indexed_db" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/io" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/isolate" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/js" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/js_util" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/math" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/mirrors" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/svg" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/typed_data" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/web_audio" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/web_gl" />
-      <root url="file://C:/flutter/bin/cache/dart-sdk/lib/web_sql" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/async" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/cli" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/collection" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/convert" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/core" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/developer" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/ffi" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/html" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/indexed_db" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/io" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/isolate" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/js" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/js_util" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/math" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/mirrors" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/svg" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/typed_data" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/web_audio" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/web_gl" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/web_sql" />
     </CLASSES>
     <JAVADOC />
     <SOURCES />

+ 1 - 1
.idea/libraries/Flutter_Plugins.xml

@@ -1,5 +1,5 @@
 <component name="libraryTable">
-  <library name="Flutter Plugins" type="FlutterPluginsLibraryType">
+  <library name="Flutter Plugins">
     <CLASSES>
       <root url="file://$PROJECT_DIR$" />
     </CLASSES>

+ 43 - 114
.idea/workspace.xml

@@ -3,12 +3,19 @@
   <component name="ChangeListManager">
     <list default="true" id="96a4f947-f66a-4efc-b495-ae979b3315bb" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/libraries/Dart_SDK.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Dart_SDK.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/android/.idea/caches/build_file_checksums.ser" beforeDir="false" afterPath="$PROJECT_DIR$/android/.idea/caches/build_file_checksums.ser" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/android/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/.idea/misc.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/android/.idea/modules.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/.idea/modules.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/android/build.gradle" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/DubbingLibPlugin.kt" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/DubbingLibPlugin.kt" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/api/DownloadHelper.kt" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/api/DownloadHelper.kt" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/api/DownloadService.kt" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/api/DownloadService.kt" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/listener/DownloadListener.kt" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/listener/DownloadListener.kt" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/util/DownloadUtil.kt" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/util/DownloadUtil.kt" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/example/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.lock" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/lib/dubbing_lib.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/dubbing_lib.dart" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.lock" afterDir="false" />
     </list>
     <ignored path="$PROJECT_DIR$/.dart_tool/" />
@@ -23,53 +30,13 @@
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
     <option name="LAST_RESOLUTION" value="IGNORE" />
   </component>
-  <component name="ExecutionTargetManager" SELECTED_TARGET="Nexus_5X_API_28" />
   <component name="FileEditorManager">
     <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/lib/dubbing_lib.dart">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="1694">
-              <caret line="77" column="3" lean-forward="true" selection-start-line="77" selection-start-column="3" selection-end-line="77" selection-end-column="3" />
-              <folding>
-                <element signature="e#0#20#0" expanded="true" />
-              </folding>
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/android/src/main/AndroidManifest.xml">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="88">
-              <caret line="4" column="69" selection-start-line="4" selection-start-column="69" selection-end-line="4" selection-end-column="69" />
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/README.md">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="308">
-              <caret line="14" selection-start-line="14" selection-end-line="14" />
-            </state>
-          </provider>
-        </entry>
-      </file>
-      <file pinned="false" current-in-tab="false">
-        <entry file="file://$PROJECT_DIR$/.gitignore">
-          <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="374">
-              <caret line="17" column="5" selection-start-line="17" selection-start-column="5" selection-end-line="17" selection-end-column="5" />
-            </state>
-          </provider>
-        </entry>
-      </file>
       <file pinned="false" current-in-tab="true">
-        <entry file="file://$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/DubbingLibPlugin.kt">
+        <entry file="file://$PROJECT_DIR$/lib/dubbing_lib.dart">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="352">
-              <caret line="75" column="46" lean-forward="true" selection-start-line="75" selection-start-column="46" selection-end-line="75" selection-end-column="46" />
+            <state relative-caret-position="478">
+              <caret line="84" column="15" selection-start-line="84" selection-start-column="7" selection-end-line="84" selection-end-column="15" />
             </state>
           </provider>
         </entry>
@@ -79,6 +46,14 @@
   <component name="FindInProjectRecents">
     <findStrings>
       <find>startCompose</find>
+      <find>startRecord</find>
+      <find>recordEvaluatorPath</find>
+      <find>playRecordAudio</find>
+      <find>pauseRecordAudio</find>
+      <find>getIsMediaPlayPause</find>
+      <find>findIsExistCacheVideo</find>
+      <find>startMixinAudio</find>
+      <find>videoPath</find>
     </findStrings>
   </component>
   <component name="Git.Settings">
@@ -88,12 +63,14 @@
     <option name="CHANGED_PATHS">
       <list>
         <option value="$PROJECT_DIR$/.gitignore" />
-        <option value="$PROJECT_DIR$/lib/dubbing_lib.dart" />
         <option value="$PROJECT_DIR$/android/build.gradle" />
+        <option value="$PROJECT_DIR$/lib/dubbing_lib.dart" />
       </list>
     </option>
   </component>
   <component name="ProjectFrameBounds" extendedState="6">
+    <option name="x" value="333" />
+    <option name="y" value="49" />
     <option name="width" value="1440" />
     <option name="height" value="900" />
   </component>
@@ -103,6 +80,7 @@
       <foldersAlwaysOnTop value="true" />
     </navigator>
     <panes>
+      <pane id="PackagesPane" />
       <pane id="Scope" />
       <pane id="ProjectPane">
         <subPane>
@@ -116,57 +94,6 @@
               <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
               <item name="android" type="462c0819:PsiDirectoryNode" />
             </path>
-            <path>
-              <item name="dubbing_lib" type="b2602c69:ProjectViewProjectNode" />
-              <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="dubbing_lib" type="b2602c69:ProjectViewProjectNode" />
-              <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="dubbing_lib" type="b2602c69:ProjectViewProjectNode" />
-              <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="kotlin" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="dubbing_lib" type="b2602c69:ProjectViewProjectNode" />
-              <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="kotlin" type="462c0819:PsiDirectoryNode" />
-              <item name="cn" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="dubbing_lib" type="b2602c69:ProjectViewProjectNode" />
-              <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="kotlin" type="462c0819:PsiDirectoryNode" />
-              <item name="cn" type="462c0819:PsiDirectoryNode" />
-              <item name="i2edu" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="dubbing_lib" type="b2602c69:ProjectViewProjectNode" />
-              <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="kotlin" type="462c0819:PsiDirectoryNode" />
-              <item name="cn" type="462c0819:PsiDirectoryNode" />
-              <item name="i2edu" type="462c0819:PsiDirectoryNode" />
-              <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
-            </path>
             <path>
               <item name="dubbing_lib" type="b2602c69:ProjectViewProjectNode" />
               <item name="dubbing_lib" type="462c0819:PsiDirectoryNode" />
@@ -176,7 +103,6 @@
           <select />
         </subPane>
       </pane>
-      <pane id="PackagesPane" />
     </panes>
   </component>
   <component name="PropertiesComponent">
@@ -213,9 +139,8 @@
   </component>
   <component name="ToolWindowManager">
     <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
-    <editor active="true" />
     <layout>
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19029851" />
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1945629" />
       <window_info id="Captures" order="1" side_tool="true" />
       <window_info id="Structure" order="2" side_tool="true" />
       <window_info id="Image Layers" order="3" />
@@ -239,7 +164,7 @@
       <window_info anchor="right" id="Capture Analysis" order="1" />
       <window_info anchor="right" id="Theme Preview" order="2" />
       <window_info anchor="right" id="Flutter Inspector" order="3" />
-      <window_info anchor="right" id="Flutter Outline" order="4" />
+      <window_info anchor="right" id="Flutter Outline" order="4" weight="0.32995737" />
       <window_info anchor="right" id="Palette&#9;" order="5" />
     </layout>
   </component>
@@ -264,41 +189,45 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/lib/dubbing_lib.dart">
-      <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="1694">
-          <caret line="77" column="3" lean-forward="true" selection-start-line="77" selection-start-column="3" selection-end-line="77" selection-end-column="3" />
-          <folding>
-            <element signature="e#0#20#0" expanded="true" />
-          </folding>
-        </state>
-      </provider>
-    </entry>
     <entry file="file://$PROJECT_DIR$/android/src/main/AndroidManifest.xml">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="88">
+        <state relative-caret-position="76">
           <caret line="4" column="69" selection-start-line="4" selection-start-column="69" selection-end-line="4" selection-end-column="69" />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/README.md">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="308">
+        <state relative-caret-position="266">
           <caret line="14" selection-start-line="14" selection-end-line="14" />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/.gitignore">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="374">
+        <state relative-caret-position="323">
           <caret line="17" column="5" selection-start-line="17" selection-start-column="5" selection-end-line="17" selection-end-column="5" />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/DubbingLibPlugin.kt">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="352">
-          <caret line="75" column="46" lean-forward="true" selection-start-line="75" selection-start-column="46" selection-end-line="75" selection-end-column="46" />
+        <state relative-caret-position="285">
+          <caret line="62" column="64" selection-start-line="62" selection-start-column="64" selection-end-line="62" selection-end-column="64" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/dubbing_lib/util/DownloadUtil.kt">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="361">
+          <caret line="19" column="98" selection-start-line="19" selection-start-column="92" selection-end-line="19" selection-end-column="98" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/lib/dubbing_lib.dart">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="478">
+          <caret line="84" column="15" selection-start-line="84" selection-start-column="7" selection-end-line="84" selection-end-column="15" />
         </state>
       </provider>
     </entry>

TEMPAT SAMPAH
android/.idea/caches/build_file_checksums.ser


+ 1 - 1
android/.idea/misc.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">

+ 1 - 0
android/.idea/modules.xml

@@ -8,6 +8,7 @@
       <module fileurl="file://$PROJECT_DIR$/../../camera_lib/android/camera_lib.iml" filepath="$PROJECT_DIR$/../../camera_lib/android/camera_lib.iml" />
       <module fileurl="file://$PROJECT_DIR$/../../../app/flutter_english_show/android/camerarecorder/camerarecorder.iml" filepath="$PROJECT_DIR$/../../../app/flutter_english_show/android/camerarecorder/camerarecorder.iml" />
       <module fileurl="file://$PROJECT_DIR$/dubbing_lib.iml" filepath="$PROJECT_DIR$/dubbing_lib.iml" />
+      <module fileurl="file://$PROJECT_DIR$/dubbing_lib-android-dubbing_lib.iml" filepath="$PROJECT_DIR$/dubbing_lib-android-dubbing_lib.iml" />
       <module fileurl="file://C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_downloader-1.3.1/android/flutter_downloader.iml" filepath="C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_downloader-1.3.1/android/flutter_downloader.iml" />
       <module fileurl="file://C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_ijkplayer-0.3.3/android/flutter_ijkplayer.iml" filepath="C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_ijkplayer-0.3.3/android/flutter_ijkplayer.iml" />
       <module fileurl="file://C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.3.0/android/path_provider.iml" filepath="C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.3.0/android/path_provider.iml" />

+ 0 - 1
android/build.gradle

@@ -47,7 +47,6 @@ android {
 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
     compileOnly  files('libs/flutter.jar')
-    implementation 'com.squareup.retrofit2:retrofit:2.6.1'
     implementation 'com.googlecode.mp4parser:isoparser:1.0-RC-37'
     implementation 'com.alibaba:fastjson:1.1.71.android'
     implementation files('libs/Msc.jar')

+ 51 - 98
android/src/main/kotlin/cn/i2edu/dubbing_lib/DubbingLibPlugin.kt

@@ -9,6 +9,7 @@ import android.os.Environment
 import android.os.Handler
 import android.os.Message
 import android.text.TextUtils
+import android.util.Log
 import android.view.View
 import android.widget.Toast
 import cn.i2edu.dubbing_lib.audioUtils.AudioDecoder
@@ -22,9 +23,7 @@ import cn.i2edu.dubbing_lib.bean.VideoData
 import cn.i2edu.dubbing_lib.callback.MixinHandlerCallback
 import cn.i2edu.dubbing_lib.util.PausableThreadPool
 import com.alibaba.fastjson.JSON
-import cn.i2edu.dubbing_lib.listener.DownloadListener
 import cn.i2edu.dubbing_lib.util.AudioEvaluatorUtil
-import cn.i2edu.dubbing_lib.util.DownloadUtil
 import cn.i2edu.dubbing_lib.util.EvaluatorCallBack
 import com.iflytek.cloud.EvaluatorResult
 import com.iflytek.cloud.SpeechConstant
@@ -49,22 +48,20 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
   private var timer: Timer? = null
   private val pausableThreadPool: PausableThreadPool = PausableThreadPool(1)
   private val mixinHandler: MixinHandler = MixinHandler(this)
-  private var mixinResult: MethodChannel.Result? = null
+  private var mixinResult: Result? = null
   private var videoData: VideoData? = null
   private var videoAudioMixer: VideoAudioMixer? = null
   private val Tag: String = "DubbingPlugin"
+  // mix in 时用到的目录
+  private var pathBgmDecodeDir: String? = null
+  private var pathBgmRecordSyncDir: String? = null
+  private var pathBgmRecordDecodeSyncDir: String? = null
+  private var pathVideoMixinDir: String? = null
 
   companion object {
     
     private lateinit var channel: MethodChannel
     val CHANNEL_NAME = "cn.hwwwwh.flutter.plugins/DubbingPlugin"
-    val PATH_AUDIO = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_record/"
-    val PATH_AUDIO_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_record_decode/"
-    val PATH_AUDIO_EVALUATOR_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_record_evaluator_decode/"
-    val PATH_BGM_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm_decode/"
-    val PATH_BGM_RECORD_SYN = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm_record_syn/"
-    val PATH_BGM_RECORD_SYN_DECODE = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm_record_syn_decode/"
-    val PATH_VIDEO_MIXIN = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_video_mixin/"
     private val BGM_DOWNLOAD_FINISHED = 0X3999
     private val AUDIO_SYN_FINISHED = 0X4001
     private val AUDIO_MIX_VIDIO_FINISHED = 0X4002
@@ -106,16 +103,16 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
           activity.window.decorView.systemUiVisibility = activity.window.decorView.systemUiVisibility.or(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
         }
       }
-      "downLoadVideo" -> {
-        downloadVideo(call.argument<String>("url")!!, result)
-      }
       "startRecord" -> {
         val duration = call.argument<Int>("duration")!!
         val fileName = call.argument<String>("fileName")!!
         val index = call.argument<Int>("index")!!
         val en = call.argument<String>("content")!!
+        val pathAudio = call.argument<String>("pathAudio")!!
+        val pathAudioDecode = call.argument<String>("pathAudioDecode")!!
+        val pathEvaluatorDecode = call.argument<String>("pathEvaluatorDecode")!!
         // 开启录音
-        initMediaRecorder(index, duration, fileName, en, result)
+        initMediaRecorder(pathAudio, pathAudioDecode, pathEvaluatorDecode, index, duration, fileName, en, result)
       }
       "playRecordAudio" -> {
         val fileName = call.argument<String>("fileName")!!
@@ -132,8 +129,10 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
         try {
           // 取得 video id, 根据前缀进行删除操作
           val videoId = call.argument<String>("videoId")!!
-          deleteFileWithPrefix(videoId, PATH_AUDIO)
-          deleteFileWithPrefix(videoId, PATH_AUDIO_DECODE)
+          val pathAudio = call.argument<String>("pathAudio")!!
+          val pathAudioDecode = call.argument<String>("pathAudioDecode")!!
+          deleteFileWithPrefix(videoId, pathAudio)
+          deleteFileWithPrefix(videoId, pathAudioDecode)
           result.success(true)
         } catch (e: Exception){
           e.printStackTrace()
@@ -144,7 +143,9 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
         try {
           // 取得 video id, 根据前缀进行查找操作
           val videoId = call.argument<String>("videoId")!!
-          val map = getExistCache(videoId)
+          val pathAudio = call.argument<String>("pathAudio")!!
+          val pathAudioDecode = call.argument<String>("pathAudioDecode")!!
+          val map = getExistCache(videoId, pathAudio, pathAudioDecode)
           result.success(map)
         } catch (e: Exception){
           e.printStackTrace()
@@ -161,6 +162,12 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
                   audioDecodePaths =  call.argument<List<String>>("audioDecodePaths")!!,
                   videoPath = call.argument<String>("videoPath")!!
           )
+          videoData!!.bgmPath = call.argument<String>("bgmPath")!!
+          pathBgmDecodeDir = call.argument<String>("pathBgmDecode")!!
+          pathBgmRecordSyncDir = call.argument<String>("pathBgmRecordSync")!!
+          pathBgmRecordDecodeSyncDir = call.argument<String>("pathBgmRecordDecodeSync")!!
+          pathVideoMixinDir = call.argument<String>("pathVideoMixin")!!
+
           mixinResult = result
           startMixinAudio()
         } catch (e: Exception){
@@ -172,40 +179,9 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
     }
   }
 
-  private fun downloadVideo(url: String, result: MethodChannel.Result) {
-    val downloadUtil = DownloadUtil()
-    downloadUtil.downloadFile(url, object : DownloadListener {
-      override fun onStart() {
-
-      }
-
-      override fun onProgress(progress: Int) {
-        activity.runOnUiThread {
-          channel.invokeMethod("downloadUpdate", mapOf("progress" to progress))
-        }
-      }
-
-      override fun onFinish(localPath: String) {
-        activity.runOnUiThread {
-          result.success(localPath)
-        }
-      }
-
-      override fun onFailure() {
-        activity.runOnUiThread {
-          result.error("10002", "下载存储错误", null)
-        }
-      }
-
-    })
-  }
-
-  private fun initMediaRecorder(index: Int, duration: Int, fileName: String, en: String, result: MethodChannel.Result) {
+  private fun initMediaRecorder(pathAudio: String, pathAudioDecode: String, pathEvaluatorDecode: String,
+                                index: Int, duration: Int, fileName: String, en: String, result: Result) {
     // create file
-    val file = File(PATH_AUDIO)
-    if (!file.exists()) {
-      file.mkdirs()
-    }
     stopRecord()
     // config media recorder
     if (mediaRecorder == null) {
@@ -218,12 +194,12 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
       mediaRecorder?.setAudioSamplingRate(44100)// 采样率
     }
     // start record
-    startRecord(index, duration, fileName, en, result)
+    startRecord(pathAudio, pathAudioDecode, pathEvaluatorDecode, index, duration, fileName, en, result)
   }
 
-  private fun startRecord(index: Int, duration: Int, fileName: String, en: String, result: MethodChannel.Result) {
+  private fun startRecord(pathAudio: String, pathAudioDecode: String, pathEvaluatorDecode: String, index: Int, duration: Int, fileName: String, en: String, result: Result) {
     if (mediaRecorder == null) return
-    val filePath = PATH_AUDIO + fileName
+    val filePath = pathAudio + fileName
     try {
       mediaRecorder?.setOutputFile(filePath)
       mediaRecorder?.prepare()
@@ -258,11 +234,11 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
                 stopRecord()
                 // 解码音频
                 Thread {
-                  decodeRecord(index, fileName, filePath)
+                  decodeRecord(pathAudioDecode, index, fileName, filePath)
                 }.start()
                 // 评测音频
                 Thread {
-                  evaluatorRecord(index, filePath, en)
+                  evaluatorRecord(pathEvaluatorDecode, index, filePath, en)
                 }.start()
               }
               break
@@ -275,10 +251,10 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
     }
   }
 
-  private fun evaluatorRecord(index: Int, recordPath: String, en: String) {
-    val dir = File(PATH_AUDIO_EVALUATOR_DECODE)
+  private fun evaluatorRecord(pathEvaluatorDecode: String, index: Int, recordPath: String, en: String) {
+    val dir = File(pathEvaluatorDecode)
     if (!dir.exists()) dir.mkdirs()
-    val decodePath = PATH_AUDIO_EVALUATOR_DECODE + "/" + UUID.randomUUID().toString() + ".pcm"
+    val decodePath = pathEvaluatorDecode + UUID.randomUUID().toString() + ".pcm"
     AudioEvaluatorUtil.getInstance(context = activity.applicationContext)
             .setEvaluatorCallBack(object : EvaluatorCallBack {
               override fun onResult(result: EvaluatorResult) {
@@ -321,8 +297,8 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
             ?.startEvaluator(en, recordPath, decodePath)
   }
 
-  private fun decodeRecord(index: Int, fileName: String, recordPath: String) {
-    val decodePath = doDecode(fileName, recordPath, PATH_AUDIO_DECODE)
+  private fun decodeRecord(pathAudioDecode: String, index: Int, fileName: String, recordPath: String) {
+    val decodePath = doDecode(fileName, recordPath, pathAudioDecode)
     if (decodePath != null && File(decodePath).exists()) {
       // 解码成功
       activity.runOnUiThread {
@@ -356,7 +332,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
     }
   }
 
-  private fun playRecord(fileName: String, result: MethodChannel.Result) {
+  private fun playRecord(fileName: String, result: Result) {
     resetMediaPlayer()
     mediaPlayer = MediaPlayer()
     mediaPlayer?.setDataSource(fileName)
@@ -395,17 +371,17 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
   }
 
   @Throws(Exception::class)
-  private fun getExistCache(video: String): Map<Int, String> {
+  private fun getExistCache(video: String, pathAudio: String, pathAudioDecode: String): Map<Int, String> {
     val map = hashMapOf<Int, String>()
 
     // 取得所有文件
-    val file = File(PATH_AUDIO)
+    val file = File(pathAudio)
     if (!file.exists()) return map
     val files = file.listFiles()
     if (files == null || files.isEmpty()) return map
 
     // 取得所有文件(这里取decode的文件)
-    val decodeFile = File(PATH_AUDIO_DECODE)
+    val decodeFile = File(pathAudioDecode)
     if (!decodeFile.exists()) return map
     val decodeFiles = decodeFile.listFiles()
     if (decodeFiles == null || decodeFiles.isEmpty()) return map
@@ -474,41 +450,18 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
   }
 
   private fun startMixinAudio() {
-    pausableThreadPool.execute {
-      // 下载背景音乐
-      val downloadUtil = DownloadUtil()
-      downloadUtil.downloadBGMFile(videoData!!.bgmUrl, object: DownloadListener {
-        override fun onStart() {
-        }
-
-        override fun onProgress(progress: Int) {
-        }
-
-        override fun onFinish(localPath: String) {
-          // 下载成功传回bgm地址
-          activity.runOnUiThread {
-            channel.invokeMethod("bgmAudioPath", mapOf("bgmPath" to localPath))
-            videoData!!.bgmPath = localPath
-            // step2 解码背景音乐
-            val message = Message.obtain()
-            message.what = BGM_DOWNLOAD_FINISHED
-            mixinHandler.sendMessage(message)
-          }
-        }
-
-        override fun onFailure() {
-          activity.runOnUiThread {
-            mixinResult?.error("1005", "down load bgm failed", "")
-          }
-        }
-      })
+    activity.runOnUiThread {
+      // step2 解码背景音乐
+      val message = Message.obtain()
+      message.what = BGM_DOWNLOAD_FINISHED
+      mixinHandler.sendMessage(message)
     }
   }
 
   private fun decodeBgmAudio(fileName:String, localPath: String) {
     if (TextUtils.isEmpty(localPath)) return
     pausableThreadPool.execute {
-      val decodedPath = doDecode(fileName, localPath, PATH_BGM_DECODE)
+      val decodedPath = doDecode(fileName, localPath, pathBgmDecodeDir!!)
       videoData?.decodeBgmPath = decodedPath
       // step3  背景音乐与录音合成
       val message = Message.obtain()
@@ -519,7 +472,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
 
   private fun syncAudios() {
     // 合成背景音乐和录音 (从尾部开始)
-    val fileDIR = File(PATH_BGM_RECORD_SYN)
+    val fileDIR = File(pathBgmRecordSyncDir)
     if (!fileDIR.exists()) {
       fileDIR.mkdirs()
     }
@@ -556,9 +509,9 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
       val accEncoder = AudioEncoder
               .createAccEncoder(videoData?.decodeAsyncBgmPath)
 //                String finalMixPath = FileBiz.get_temp_recorders_dir() + "/" + UUID.randomUUID() + ".mp4";
-      val file = File(PATH_BGM_RECORD_SYN_DECODE)
+      val file = File(pathBgmRecordDecodeSyncDir)
       if (!file.exists()) file.mkdirs()
-      val finalMixPath = PATH_BGM_RECORD_SYN_DECODE + "mixinDecode.aac"
+      val finalMixPath = pathBgmRecordDecodeSyncDir + "mixinDecode.aac"
       val isEncodeFinished = !TextUtils.isEmpty(accEncoder.encodeToFile(finalMixPath))
       if (!isEncodeFinished) {
         activity.runOnUiThread{
@@ -580,7 +533,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
       }
       videoAudioMixer?.setListener(object: VideoAudioMixer.VideoAudioMixListener {
         override fun mixSuccess() {
-          videoData?.mixVideoPath = PATH_VIDEO_MIXIN + "${videoData?.videoId}_mix.mp4"
+          videoData?.mixVideoPath = pathVideoMixinDir + "${videoData?.videoId}_mix.mp4"
           val msg = Message()
           msg.what = AUDIO_MIX_VIDIO_FINISHED
           mixinHandler.sendMessage(msg)
@@ -593,7 +546,7 @@ class DubbingLibPlugin: MethodCallHandler, MixinHandlerCallback {
         }
       })
       videoAudioMixer?.mux(videoData?.encodeAudioWithBgmPath, videoData?.videoPath,
-              "${videoData?.videoId}_mix.mp4", PATH_VIDEO_MIXIN)
+              "${videoData?.videoId}_mix.mp4", pathVideoMixinDir)
     }
   }
 

+ 41 - 41
android/src/main/kotlin/cn/i2edu/dubbing_lib/api/DownloadHelper.kt

@@ -1,41 +1,41 @@
-package cn.i2edu.dubbing_lib.api
-
-import okhttp3.OkHttpClient
-import retrofit2.Retrofit
-import java.util.concurrent.TimeUnit
-
-class DownloadHelper {
-    companion object {
-        val Tag: String = "DownloadHelper"
-        // kotlin DLC mode
-        val instance: DownloadHelper by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
-            DownloadHelper()
-        }
-    }
-
-    private lateinit var mRetrofit: Retrofit
-    private lateinit var mHttpClient: OkHttpClient
-
-    constructor(): this(30, 30, 30)
-
-    constructor(connectTimeOut: Long, readTimeOut: Long, writeTimeOut: Long) {
-        val builder = OkHttpClient.Builder()
-                .connectTimeout(connectTimeOut, TimeUnit.SECONDS)
-                .readTimeout(readTimeOut, TimeUnit.SECONDS)
-                .writeTimeout(writeTimeOut, TimeUnit.SECONDS);
-        mHttpClient = builder.build()
-    }
-
-    fun buildRetrofit(baseUrl: String): DownloadHelper {
-        mRetrofit = Retrofit.Builder()
-                .baseUrl(baseUrl)
-                .client(mHttpClient)
-                .build()
-        return this
-    }
-
-    public fun <T> createRetrofit(serviceClass: Class<T>): T {
-        return mRetrofit.create(serviceClass)
-    }
-
-}
+//package cn.i2edu.dubbing_lib.api
+//
+//import okhttp3.OkHttpClient
+//import retrofit2.Retrofit
+//import java.util.concurrent.TimeUnit
+//
+//class DownloadHelper {
+//    companion object {
+//        val Tag: String = "DownloadHelper"
+//        // kotlin DLC mode
+//        val instance: DownloadHelper by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
+//            DownloadHelper()
+//        }
+//    }
+//
+//    private lateinit var mRetrofit: Retrofit
+//    private lateinit var mHttpClient: OkHttpClient
+//
+//    constructor(): this(30, 30, 30)
+//
+//    constructor(connectTimeOut: Long, readTimeOut: Long, writeTimeOut: Long) {
+//        val builder = OkHttpClient.Builder()
+//                .connectTimeout(connectTimeOut, TimeUnit.SECONDS)
+//                .readTimeout(readTimeOut, TimeUnit.SECONDS)
+//                .writeTimeout(writeTimeOut, TimeUnit.SECONDS);
+//        mHttpClient = builder.build()
+//    }
+//
+//    fun buildRetrofit(baseUrl: String): DownloadHelper {
+//        mRetrofit = Retrofit.Builder()
+//                .baseUrl(baseUrl)
+//                .client(mHttpClient)
+//                .build()
+//        return this
+//    }
+//
+//    public fun <T> createRetrofit(serviceClass: Class<T>): T {
+//        return mRetrofit.create(serviceClass)
+//    }
+//
+//}

+ 13 - 13
android/src/main/kotlin/cn/i2edu/dubbing_lib/api/DownloadService.kt

@@ -1,13 +1,13 @@
-package cn.i2edu.dubbing_lib.api
-
-import okhttp3.ResponseBody
-import retrofit2.Call
-import retrofit2.http.GET
-import retrofit2.http.Streaming
-import retrofit2.http.Url
-
-interface DownloadService {
-    @Streaming
-    @GET
-    fun downFile(@Url fileUrl:String): Call<ResponseBody>
-}
+//package cn.i2edu.dubbing_lib.api
+//
+//import okhttp3.ResponseBody
+//import retrofit2.Call
+//import retrofit2.http.GET
+//import retrofit2.http.Streaming
+//import retrofit2.http.Url
+//
+//interface DownloadService {
+//    @Streaming
+//    @GET
+//    fun downFile(@Url fileUrl:String): Call<ResponseBody>
+//}

+ 11 - 11
android/src/main/kotlin/cn/i2edu/dubbing_lib/listener/DownloadListener.kt

@@ -1,11 +1,11 @@
-package cn.i2edu.dubbing_lib.listener
-
-interface DownloadListener {
-    fun onStart()
-
-    fun onProgress(progress: Int)
-
-    fun onFinish(localPath: String)
-
-    fun onFailure();
-}
+//package cn.i2edu.dubbing_lib.listener
+//
+//interface DownloadListener {
+//    fun onStart()
+//
+//    fun onProgress(progress: Int)
+//
+//    fun onFinish(localPath: String)
+//
+//    fun onFailure();
+//}

+ 141 - 141
android/src/main/kotlin/cn/i2edu/dubbing_lib/util/DownloadUtil.kt

@@ -1,141 +1,141 @@
-package cn.i2edu.dubbing_lib.util
-
-import android.os.Environment
-import android.util.Log
-import cn.i2edu.dubbing_lib.api.DownloadHelper
-import okhttp3.ResponseBody
-import retrofit2.Call
-import cn.i2edu.dubbing_lib.api.DownloadService
-import cn.i2edu.dubbing_lib.listener.DownloadListener
-import retrofit2.Callback
-import retrofit2.Response
-import java.io.*
-
-
-class DownloadUtil {
-
-    companion object {
-        private val Tag: String = "DownloadUtil"
-        val PATH_VIDEO = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_video/"
-        val PATH_BGM = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm/"
-    }
-
-    protected lateinit var mApi: DownloadService
-    private var mCall: Call<ResponseBody>? = null
-    private var mThread: Thread? = null
-
-    constructor() {
-        if (!this::mApi.isInitialized) {
-            mApi = DownloadHelper.instance.buildRetrofit(" http://cdn.i2nexted.com/upload/video/file/")
-                    .createRetrofit(DownloadService::class.java)
-        }
-    }
-
-    fun downloadFile(url: String, downloadListener: DownloadListener) {
-        downloadListener.onStart()
-        val file = File(PATH_VIDEO)
-        if (!file.exists()) {
-            file.mkdirs()
-        }
-        var name = url
-        val i = url.lastIndexOf('/')
-        if (i == -1) {
-            return
-        }
-        name = PATH_VIDEO + name.substring(i)
-        val mFile = File(name)
-        if (!mFile.exists()) {
-            if (!mFile.createNewFile()) {
-                return
-            }
-        }
-        // 下载
-        mCall = mApi.downFile(url)
-        mCall?.enqueue(object : Callback<ResponseBody>{
-            override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
-                downloadListener.onFailure()
-            }
-
-            override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
-                mThread = Thread {
-                    saveToFile(response, mFile, downloadListener)
-                }
-                mThread?.start()
-            }
-        })
-    }
-
-    /**
-     * download BGM file with [url] and  [downloadListener]
-     */
-    fun downloadBGMFile(url: String, downloadListener: DownloadListener) {
-        downloadListener.onStart()
-        val file = File(PATH_BGM)
-        if (!file.exists()) {
-            file.mkdirs()
-        }
-        var name = url
-        val i = url.lastIndexOf('/')
-        if (i == -1) {
-            return
-        }
-        name = PATH_BGM + name.substring(i)
-        val mFile = File(name)
-        if (!mFile.exists()) {
-            if (!mFile.createNewFile()) {
-                return
-            }
-        }
-        // 下载
-        mCall = mApi.downFile(url)
-        mCall?.enqueue(object : Callback<ResponseBody>{
-            override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
-                downloadListener.onFailure()
-            }
-
-            override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
-                mThread = Thread {
-                    saveToFile(response, mFile, downloadListener)
-                }
-                mThread?.start()
-            }
-        })
-    }
-
-    private fun saveToFile(response: Response<ResponseBody>, mFile: File, downloadListener: DownloadListener) {
-        var currentLength: Long = 0
-        var os: OutputStream? = null
-
-        val iStream = response.body()?.byteStream()
-        val totalLength = response.body()?.contentLength()
-
-        try {
-            os = FileOutputStream(mFile)
-            val buff = ByteArray(1024)
-            do{
-                val len = iStream!!.read(buff)
-                if (len == -1) {
-                    break
-                }
-                os.write(buff, 0, len)
-                currentLength += len
-                Log.i(Tag, "当前进度: ${(100 * currentLength / totalLength!!).toInt()}")
-                //计算当前下载百分比,并经由回调传出
-                downloadListener.onProgress((100 * currentLength / totalLength!!).toInt())
-                //当百分比为100时下载结束,调用结束回调,并传出下载后的本地路径
-                if ((100 * currentLength / totalLength).toInt() == 100) {
-                    downloadListener.onFinish(mFile.absolutePath)//下载完成
-                }
-            } while (true)
-        } catch (e: FileNotFoundException) {
-            e.printStackTrace()
-        } catch (e: IOException) {
-            e.printStackTrace()
-        } finally {
-            os?.close()
-            iStream?.close()
-        }
-
-    }
-
-}
+//package cn.i2edu.dubbing_lib.util
+//
+//import android.os.Environment
+//import android.util.Log
+//import cn.i2edu.dubbing_lib.api.DownloadHelper
+//import okhttp3.ResponseBody
+//import retrofit2.Call
+//import cn.i2edu.dubbing_lib.api.DownloadService
+//import cn.i2edu.dubbing_lib.listener.DownloadListener
+//import retrofit2.Callback
+//import retrofit2.Response
+//import java.io.*
+//
+//
+//class DownloadUtil {
+//
+//    companion object {
+//        private val Tag: String = "DownloadUtil"
+//        val PATH_VIDEO = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_video/"
+//        val PATH_BGM = "${Environment.getExternalStorageDirectory().absoluteFile}/i2_file/i2_bgm/"
+//    }
+//
+//    protected lateinit var mApi: DownloadService
+//    private var mCall: Call<ResponseBody>? = null
+//    private var mThread: Thread? = null
+//
+//    constructor() {
+//        if (!this::mApi.isInitialized) {
+//            mApi = DownloadHelper.instance.buildRetrofit(" http://cdn.i2nexted.com/upload/video/file/")
+//                    .createRetrofit(DownloadService::class.java)
+//        }
+//    }
+//
+//    fun downloadFile(url: String, downloadListener: DownloadListener) {
+//        downloadListener.onStart()
+//        val file = File(PATH_VIDEO)
+//        if (!file.exists()) {
+//            file.mkdirs()
+//        }
+//        var name = url
+//        val i = url.lastIndexOf('/')
+//        if (i == -1) {
+//            return
+//        }
+//        name = PATH_VIDEO + name.substring(i)
+//        val mFile = File(name)
+//        if (!mFile.exists()) {
+//            if (!mFile.createNewFile()) {
+//                return
+//            }
+//        }
+//        // 下载
+//        mCall = mApi.downFile(url)
+//        mCall?.enqueue(object : Callback<ResponseBody>{
+//            override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
+//                downloadListener.onFailure()
+//            }
+//
+//            override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
+//                mThread = Thread {
+//                    saveToFile(response, mFile, downloadListener)
+//                }
+//                mThread?.start()
+//            }
+//        })
+//    }
+//
+//    /**
+//     * download BGM file with [url] and  [downloadListener]
+//     */
+//    fun downloadBGMFile(url: String, downloadListener: DownloadListener) {
+//        downloadListener.onStart()
+//        val file = File(PATH_BGM)
+//        if (!file.exists()) {
+//            file.mkdirs()
+//        }
+//        var name = url
+//        val i = url.lastIndexOf('/')
+//        if (i == -1) {
+//            return
+//        }
+//        name = PATH_BGM + name.substring(i)
+//        val mFile = File(name)
+//        if (!mFile.exists()) {
+//            if (!mFile.createNewFile()) {
+//                return
+//            }
+//        }
+//        // 下载
+//        mCall = mApi.downFile(url)
+//        mCall?.enqueue(object : Callback<ResponseBody>{
+//            override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
+//                downloadListener.onFailure()
+//            }
+//
+//            override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
+//                mThread = Thread {
+//                    saveToFile(response, mFile, downloadListener)
+//                }
+//                mThread?.start()
+//            }
+//        })
+//    }
+//
+//    private fun saveToFile(response: Response<ResponseBody>, mFile: File, downloadListener: DownloadListener) {
+//        var currentLength: Long = 0
+//        var os: OutputStream? = null
+//
+//        val iStream = response.body()?.byteStream()
+//        val totalLength = response.body()?.contentLength()
+//
+//        try {
+//            os = FileOutputStream(mFile)
+//            val buff = ByteArray(1024)
+//            do{
+//                val len = iStream!!.read(buff)
+//                if (len == -1) {
+//                    break
+//                }
+//                os.write(buff, 0, len)
+//                currentLength += len
+//                Log.i(Tag, "当前进度: ${(100 * currentLength / totalLength!!).toInt()}")
+//                //计算当前下载百分比,并经由回调传出
+//                downloadListener.onProgress((100 * currentLength / totalLength!!).toInt())
+//                //当百分比为100时下载结束,调用结束回调,并传出下载后的本地路径
+//                if ((100 * currentLength / totalLength).toInt() == 100) {
+//                    downloadListener.onFinish(mFile.absolutePath)//下载完成
+//                }
+//            } while (true)
+//        } catch (e: FileNotFoundException) {
+//            e.printStackTrace()
+//        } catch (e: IOException) {
+//            e.printStackTrace()
+//        } finally {
+//            os?.close()
+//            iStream?.close()
+//        }
+//
+//    }
+//
+//}

+ 18 - 18
example/pubspec.lock

@@ -5,35 +5,35 @@ packages:
     dependency: transitive
     description:
       name: async
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.3.0"
   boolean_selector:
     dependency: transitive
     description:
       name: boolean_selector
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.0.5"
   charcode:
     dependency: transitive
     description:
       name: charcode
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.2"
   collection:
     dependency: transitive
     description:
       name: collection
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.14.11"
   cupertino_icons:
     dependency: "direct main"
     description:
       name: cupertino_icons
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "0.1.2"
   dubbing_lib:
@@ -57,35 +57,35 @@ packages:
     dependency: transitive
     description:
       name: matcher
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "0.12.5"
   meta:
     dependency: transitive
     description:
       name: meta
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.7"
   path:
     dependency: transitive
     description:
       name: path
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.6.4"
   pedantic:
     dependency: transitive
     description:
       name: pedantic
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.8.0+1"
   quiver:
     dependency: transitive
     description:
       name: quiver
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.0.5"
   sky_engine:
@@ -97,56 +97,56 @@ packages:
     dependency: transitive
     description:
       name: source_span
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.5.5"
   stack_trace:
     dependency: transitive
     description:
       name: stack_trace
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.9.3"
   stream_channel:
     dependency: transitive
     description:
       name: stream_channel
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.0.0"
   string_scanner:
     dependency: transitive
     description:
       name: string_scanner
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.0.5"
   term_glyph:
     dependency: transitive
     description:
       name: term_glyph
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.0"
   test_api:
     dependency: transitive
     description:
       name: test_api
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "0.2.5"
   typed_data:
     dependency: transitive
     description:
       name: typed_data
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.6"
   vector_math:
     dependency: transitive
     description:
       name: vector_math
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.0.8"
 sdks:

+ 35 - 7
lib/dubbing_lib.dart

@@ -1,5 +1,6 @@
 import 'dart:async';
 
+import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 
 class DubbingLib {
@@ -20,6 +21,16 @@ class DubbingLib {
   Stream<int> get recordProgressChange => _onRecordProgressChange.stream;
   Stream<Map> get decodeResultChange => _onDecodeResultChange.stream;
   Stream<Map> get evaluatorResultChange => _onEvaluatorResultChange.stream;
+  /// 路径文件夹地址
+  String videoPath;
+  String recordPath;
+  String recordDecodePath;
+  String recordEvaluatorPath;
+  String bgmPath;
+  String bgmDecodePath;
+  String audioSyncPath;
+  String audioSyncDecodePath;
+  String videoMixInPath;
 
   static Future<String> get platformVersion async {
     final String version = await _channel.invokeMethod('getPlatformVersion');
@@ -35,8 +46,8 @@ class DubbingLib {
     return _channel.invokeMethod("setExtraFullScreen");
   }
 
-  Future<Map<dynamic, dynamic>> findIsExistCacheVideo(String videoId) {
-    return _channel.invokeMethod<Map<dynamic, dynamic>>("findIsExistCacheVideo", {"videoId": videoId});
+  Future<Map<dynamic, dynamic>> findIsExistCacheVideo(String videoId, {String recordPath, String recordDecodePath}) {
+    return _channel.invokeMethod<Map<dynamic, dynamic>>("findIsExistCacheVideo", {"videoId": videoId, "pathAudio": recordPath ?? this.recordPath, "pathAudioDecode": recordDecodePath ?? this.recordDecodePath});
   }
 
   Future<String> downLoadVideo(String videoUrl) {
@@ -49,24 +60,41 @@ class DubbingLib {
 
   /// 返回录音文件地址
   Future<String> startRecord(int index, int duration, String fileName, String content) {
-    return _channel.invokeMethod("startRecord", {"duration": duration, "fileName": fileName, "index": index, "content": content});
+    return _channel.invokeMethod("startRecord",
+        {"duration": duration, "fileName": fileName, "index": index, "content": content, "pathAudio": recordPath, "pathAudioDecode": recordDecodePath, "pathEvaluatorDecode": recordEvaluatorPath}
+        );
   }
 
   Future<void> playRecordAudio(String filePath) {
     return _channel.invokeMethod("playRecordAudio", {"fileName": filePath});
   }
 
-  /// 返回合成视频文件地址
-  Future<String> startMixinAudio(String videoId, String bgmUrl, List<int> endTimeList,
+  /// 返回合成视频文件地址 这里的bgmPath是已经下载的背景音乐文件地址
+  Future<String> startMixinAudio(String videoId, String bgmUrl, String bgmPath, List<int> endTimeList,
       List<String> decodeAudioPathList, List<int> durationList, String localVideoPath) {
     return _channel.invokeMethod("startMixinAudio", {"videoId": videoId, "bgmUrl": bgmUrl,
-      "endTimeList": endTimeList, "audioDecodePaths": decodeAudioPathList, "durationList": durationList, "videoPath": localVideoPath});
+      "endTimeList": endTimeList, "audioDecodePaths": decodeAudioPathList, "durationList": durationList, "videoPath": localVideoPath,
+      "bgmPath": bgmPath, "pathBgmDecode": bgmDecodePath, "pathBgmRecordSync": audioSyncPath, "pathBgmRecordDecodeSync": audioSyncDecodePath, "pathVideoMixin": videoMixInPath});
   }
 
   Future<void> cleanAudioData(String videoId) {
-    return _channel.invokeMethod("cleanAudioData", {"videoId": videoId});
+    return _channel.invokeMethod("cleanAudioData", {"videoId": videoId, "pathAudio": recordPath, "pathAudioDecode": recordDecodePath});
   }
 
+  /// 初始化路径
+  void initPath({@required String videoPath, @required String recordPath, @required String recordDecodePath, @required String recordEvaluatorPath,
+    @required String bgmPath, @required String bgmDecodePath, @required String audioSyncPath, @required String audioSyncDecodePath,
+    @required String videoMixInPath}) {
+    this.videoPath = videoPath;
+    this.recordPath = recordPath;
+    this.recordDecodePath = recordDecodePath;
+    this.recordEvaluatorPath = recordEvaluatorPath;
+    this.bgmPath = bgmPath;
+    this.bgmDecodePath = bgmDecodePath;
+    this.audioSyncPath = audioSyncPath;
+    this.audioSyncDecodePath = audioSyncDecodePath;
+    this. videoMixInPath = videoMixInPath;
+  }
 
   /// 初始化listener 进入录音页面时调用
   void initListener() {

+ 17 - 17
pubspec.lock

@@ -5,28 +5,28 @@ packages:
     dependency: transitive
     description:
       name: async
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.3.0"
   boolean_selector:
     dependency: transitive
     description:
       name: boolean_selector
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.0.5"
   charcode:
     dependency: transitive
     description:
       name: charcode
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.2"
   collection:
     dependency: transitive
     description:
       name: collection
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.14.11"
   flutter:
@@ -43,35 +43,35 @@ packages:
     dependency: transitive
     description:
       name: matcher
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "0.12.5"
   meta:
     dependency: transitive
     description:
       name: meta
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.7"
   path:
     dependency: transitive
     description:
       name: path
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.6.4"
   pedantic:
     dependency: transitive
     description:
       name: pedantic
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.8.0+1"
   quiver:
     dependency: transitive
     description:
       name: quiver
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.0.5"
   sky_engine:
@@ -83,56 +83,56 @@ packages:
     dependency: transitive
     description:
       name: source_span
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.5.5"
   stack_trace:
     dependency: transitive
     description:
       name: stack_trace
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.9.3"
   stream_channel:
     dependency: transitive
     description:
       name: stream_channel
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.0.0"
   string_scanner:
     dependency: transitive
     description:
       name: string_scanner
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.0.5"
   term_glyph:
     dependency: transitive
     description:
       name: term_glyph
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.0"
   test_api:
     dependency: transitive
     description:
       name: test_api
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "0.2.5"
   typed_data:
     dependency: transitive
     description:
       name: typed_data
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "1.1.6"
   vector_math:
     dependency: transitive
     description:
       name: vector_math
-      url: "https://pub.flutter-io.cn"
+      url: "https://pub.dartlang.org"
     source: hosted
     version: "2.0.8"
 sdks: