@@ -63,7 +63,7 @@ class AudioRecorder(private val context: Context) {
6363 callback : RecordingCallback
6464 ): Boolean {
6565 if (isRecording) {
66- " 录制已在进行中" .logW(TAG , " 录制已在进行中 " )
66+ " 录制已在进行中" .logW(TAG )
6767 return false
6868 }
6969 this .callback = callback
@@ -75,13 +75,13 @@ class AudioRecorder(private val context: Context) {
7575
7676 isRecording = true
7777 startTime = System .currentTimeMillis()
78- " 开始录制: ${this .outputFile?.absolutePath} " .logD(TAG , " 开始录制: ${ this .outputFile?.absolutePath} " )
78+ " 开始录制: ${this .outputFile?.absolutePath} " .logD(TAG )
7979 callback.onStart()
8080
8181 true
8282 } catch (e: Exception ) {
8383 val errorMsg = " 开始录制失败: ${e.message} "
84- errorMsg.logE(TAG , errorMsg )
84+ errorMsg.logE(TAG )
8585 cleanup()
8686 callback.onError(errorMsg)
8787 false
@@ -95,7 +95,7 @@ class AudioRecorder(private val context: Context) {
9595 */
9696 fun stopRecording (): File ? {
9797 if (! isRecording) {
98- " 当前未在录制" .logW(TAG , " 当前未在录制 " )
98+ " 当前未在录制" .logW(TAG )
9999 return null
100100 }
101101
@@ -110,7 +110,7 @@ class AudioRecorder(private val context: Context) {
110110
111111 isRecording = false
112112
113- " 录制已停止,时长: ${duration} ms,文件: ${file?.absolutePath} " .logD(TAG , " 录制已停止,时长: ${duration} ms,文件: ${file?.absolutePath} " )
113+ " 录制已停止,时长: ${duration} ms,文件: ${file?.absolutePath} " .logD(TAG )
114114
115115 if (file != null && file.exists()) {
116116 callback?.onComplete(file, duration)
@@ -121,7 +121,7 @@ class AudioRecorder(private val context: Context) {
121121 }
122122 } catch (e: RuntimeException ) {
123123 val errorMsg = " 停止录制失败: ${e.message} "
124- errorMsg.logE(TAG , errorMsg )
124+ errorMsg.logE(TAG )
125125 callback?.onError(errorMsg)
126126 null
127127 } finally {
@@ -134,7 +134,7 @@ class AudioRecorder(private val context: Context) {
134134 */
135135 fun cancelRecording () {
136136 if (! isRecording) {
137- " 当前未在录制" .logW(TAG , " 当前未在录制 " )
137+ " 当前未在录制" .logW(TAG )
138138 return
139139 }
140140
@@ -148,15 +148,15 @@ class AudioRecorder(private val context: Context) {
148148 outputFile?.let {
149149 if (it.exists()) {
150150 it.delete()
151- " 录制文件已删除: ${it.absolutePath} " .logD(TAG , " 录制文件已删除: ${it.absolutePath} " )
151+ " 录制文件已删除: ${it.absolutePath} " .logD(TAG )
152152 }
153153 }
154154
155155 isRecording = false
156156
157- " 录制已取消" .logD(TAG , " 录制已取消 " )
157+ " 录制已取消" .logD(TAG )
158158 } catch (e: Exception ) {
159- " 取消录制失败: ${e.message} " .logE(TAG , " 取消录制失败: ${e.message} " )
159+ " 取消录制失败: ${e.message} " .logE(TAG )
160160 } finally {
161161 cleanup()
162162 }
@@ -198,7 +198,7 @@ class AudioRecorder(private val context: Context) {
198198 }
199199 cleanup()
200200 callback = null
201- " 录制器已释放" .logD(TAG , " 录制器已释放 " )
201+ " 录制器已释放" .logD(TAG )
202202 }
203203
204204 private fun createTempAudioFile (extension : String ): File {
@@ -252,7 +252,7 @@ class AudioRecorder(private val context: Context) {
252252 // 设置错误监听器
253253 setOnErrorListener { _, what, extra ->
254254 val errorMsg = " 录制错误: what=$what , extra=$extra "
255- errorMsg.logE(TAG , errorMsg )
255+ errorMsg.logE(TAG )
256256 callback?.onError(errorMsg)
257257 }
258258
@@ -268,7 +268,7 @@ class AudioRecorder(private val context: Context) {
268268 mediaRecorder?.release()
269269 mediaRecorder = null
270270 } catch (e: Exception ) {
271- " 释放录制器失败: ${e.message} " .logE(TAG , " 释放录制器失败: ${e.message} " )
271+ " 释放录制器失败: ${e.message} " .logE(TAG )
272272 }
273273 }
274274}
0 commit comments