@@ -49,17 +49,17 @@ public TiAudioRecorder()
49
49
50
50
public boolean isPaused ()
51
51
{
52
- return paused ;
52
+ return this . paused ;
53
53
}
54
54
55
55
public boolean isRecording ()
56
56
{
57
- return recording ;
57
+ return this . recording ;
58
58
}
59
59
60
60
public boolean isStopped ()
61
61
{
62
- return stopped ;
62
+ return this . stopped ;
63
63
}
64
64
65
65
public void startRecording ()
@@ -82,7 +82,9 @@ public void startRecording()
82
82
audioRecord .setPositionNotificationPeriod (bufferSize / 4 );
83
83
audioRecord .startRecording ();
84
84
audioRecord .read (audioData , 0 , bufferSize );
85
- recording = true ;
85
+ this .recording = true ;
86
+ this .paused = false ;
87
+ this .stopped = false ;
86
88
}
87
89
}
88
90
@@ -91,39 +93,51 @@ public String stopRecording()
91
93
File resultFile = null ;
92
94
//Guard for calling stop before starting the recording
93
95
if (audioRecord != null ) {
96
+ // Update state.
97
+ this .recording = false ;
98
+ this .paused = false ;
99
+ this .stopped = true ;
100
+
101
+ // Stop recording.
94
102
int recordState = audioRecord .getState ();
95
103
if (recordState == 1 ) {
96
104
audioRecord .stop ();
97
105
}
98
106
audioRecord .setRecordPositionUpdateListener (null );
99
107
audioRecord .release ();
100
108
audioRecord = null ;
109
+
110
+ // Write recording to file.
101
111
try {
102
112
resultFile = TiFileHelper .getInstance ().getTempFile (AUDIO_RECORDER_FILE_EXT_WAV , true );
103
113
createWaveFile (resultFile .getAbsolutePath ());
104
114
} catch (IOException e ) {
105
115
e .printStackTrace ();
106
116
}
107
117
}
108
- return resultFile != null ? resultFile .getAbsolutePath () : "" ;
118
+ return resultFile != null ? resultFile .getAbsolutePath () : null ;
109
119
}
110
120
111
121
public void pauseRecording ()
112
122
{
113
123
//Guard for calling pause before starting the recording
114
124
if (audioRecord != null ) {
115
- paused = true ;
116
125
audioRecord .stop ();
126
+ this .recording = false ;
127
+ this .paused = true ;
128
+ this .stopped = false ;
117
129
}
118
130
}
119
131
120
132
public void resumeRecording ()
121
133
{
122
134
//Guard for calling resume before starting the recording
123
135
if (audioRecord != null ) {
124
- paused = false ;
125
136
audioRecord .startRecording ();
126
137
audioRecord .read (audioData , 0 , bufferSize );
138
+ this .recording = true ;
139
+ this .paused = false ;
140
+ this .stopped = false ;
127
141
}
128
142
}
129
143
0 commit comments