@@ -130,7 +130,9 @@ public void destroy() {
130
130
this .player = null ;
131
131
}
132
132
if (this .recorder != null ) {
133
- this .stopRecording (true );
133
+ if (this .state != STATE .MEDIA_STOPPED ) {
134
+ this .stopRecording (true );
135
+ }
134
136
this .recorder .release ();
135
137
this .recorder = null ;
136
138
}
@@ -197,8 +199,44 @@ public void moveFile(String file) {
197
199
if (size == 1 ) {
198
200
String logMsg = "renaming " + this .tempFile + " to " + file ;
199
201
LOG .d (LOG_TAG , logMsg );
202
+
200
203
File f = new File (this .tempFile );
201
- if (!f .renameTo (new File (file ))) LOG .e (LOG_TAG , "FAILED " + logMsg );
204
+ if (!f .renameTo (new File (file ))) {
205
+
206
+ FileOutputStream outputStream = null ;
207
+ File outputFile = null ;
208
+ try {
209
+ outputFile = new File (file );
210
+ outputStream = new FileOutputStream (outputFile );
211
+ FileInputStream inputStream = null ;
212
+ File inputFile = null ;
213
+ try {
214
+ inputFile = new File (this .tempFile );
215
+ LOG .d (LOG_TAG , "INPUT FILE LENGTH: " + String .valueOf (inputFile .length ()) );
216
+ inputStream = new FileInputStream (inputFile );
217
+ copy (inputStream , outputStream , false );
218
+ } catch (Exception e ) {
219
+ LOG .e (LOG_TAG , e .getLocalizedMessage (), e );
220
+ } finally {
221
+ if (inputStream != null ) try {
222
+ inputStream .close ();
223
+ inputFile .delete ();
224
+ inputFile = null ;
225
+ } catch (Exception e ) {
226
+ LOG .e (LOG_TAG , e .getLocalizedMessage (), e );
227
+ }
228
+ }
229
+ } catch (Exception e ) {
230
+ e .printStackTrace ();
231
+ } finally {
232
+ if (outputStream != null ) try {
233
+ outputStream .close ();
234
+ LOG .d (LOG_TAG , "OUTPUT FILE LENGTH: " + String .valueOf (outputFile .length ()) );
235
+ } catch (Exception e ) {
236
+ LOG .e (LOG_TAG , e .getLocalizedMessage (), e );
237
+ }
238
+ }
239
+ }
202
240
}
203
241
// more than one file so the user must have pause recording. We'll need to concat files.
204
242
else {
0 commit comments