GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 0.0.7 · CoderEslam/AndroidAudioRecorder@0f2890e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • app
    • build.gradle
  • build.gradle
  • gradle/wrapper
    • gradle-wrapper.properties
  • lib
    • build.gradle
    • src/main
      • java/cafe/adriel/androidaudiorecorder
        • AudioRecorderActivity.java
      • res
        • values-pt
          • strings.xml
        • values
          • strings.xml
  • screenshots.png
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ repositories {
5151
}
5252
5353
dependencies {
54-
compile 'com.github.adrielcafe:AndroidAudioRecorder:0.0.6'
54+
compile 'com.github.adrielcafe:AndroidAudioRecorder:0.0.7'
5555
}
5656
```
5757

@@ -60,7 +60,7 @@ dependencies {
6060
- [X] Tint images to black when background color is too bright (thanks to [@prakh25](https://github.com/prakh25))
6161
- [X] Wave visualization based on this [player concept](https://dribbble.com/shots/2369760-Player-Concept)
6262
- [X] Play recorded audio
63-
- [ ] Pause audio
63+
- [X] Pause recording
6464
- [ ] Skip silence
6565

6666
## Dependencies
Collapse file

‎app/build.gradle‎

Copy file name to clipboardExpand all lines: app/build.gradle
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ android {
2121
dependencies {
2222
compile 'com.android.support:appcompat-v7:24.1.1'
2323
compile project(':lib')
24-
// compile 'com.github.adrielcafe:AndroidAudioRecorder:0.0.6'
24+
// compile 'com.github.adrielcafe:AndroidAudioRecorder:0.0.7'
2525
}
2626

2727
repositories {
Collapse file

‎build.gradle‎

Copy file name to clipboardExpand all lines: build.gradle
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
jcenter()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:2.1.2'
6+
classpath 'com.android.tools.build:gradle:2.1.3'
77
}
88
}
99

Collapse file

‎gradle/wrapper/gradle-wrapper.properties‎

Copy file name to clipboard
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Aug 02 09:48:12 BRT 2016
1+
#Thu Aug 25 11:20:16 BRT 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Collapse file

‎lib/build.gradle‎

Copy file name to clipboardExpand all lines: lib/build.gradle
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ android {
2020

2121
dependencies {
2222
compile 'com.android.support:appcompat-v7:24.1.1'
23-
compile 'com.kailashdabhi:om-recorder:1.0.1'
23+
compile 'com.kailashdabhi:om-recorder:1.1.0'
2424
compile 'com.cleveroad:audiovisualization:0.9.4'
2525
}
Collapse file

‎lib/src/main/java/cafe/adriel/androidaudiorecorder/AudioRecorderActivity.java‎

Copy file name to clipboardExpand all lines: lib/src/main/java/cafe/adriel/androidaudiorecorder/AudioRecorderActivity.java
+49-39Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
import omrecorder.Recorder;
2727

2828
public class AudioRecorderActivity extends AppCompatActivity
29-
implements PullTransport.OnAudioChunkPulledListener,
30-
MediaPlayer.OnCompletionListener, MediaPlayer.OnPreparedListener {
29+
implements PullTransport.OnAudioChunkPulledListener, MediaPlayer.OnCompletionListener {
3130

3231
private MediaPlayer player;
3332
private Recorder recorder;
@@ -38,7 +37,8 @@ public class AudioRecorderActivity extends AppCompatActivity
3837

3938
private Timer timer;
4039
private MenuItem saveMenuItem;
41-
private int secondsElapsed;
40+
private int recorderSecondsElapsed;
41+
private int playerSecondsElapsed;
4242
private boolean isRecording;
4343

4444
private RelativeLayout contentLayout;
@@ -120,7 +120,7 @@ public void onResume() {
120120

121121
@Override
122122
protected void onPause() {
123-
stopRecording();
123+
restartRecording(null);
124124
try {
125125
visualizerView.onPause();
126126
} catch (Exception e){ }
@@ -168,19 +168,13 @@ public void onAudioChunkPulled(AudioChunk audioChunk) {
168168
visualizerHandler.onDataReceived(amplitude);
169169
}
170170

171-
@Override
172-
public void onPrepared(final MediaPlayer mediaPlayer) {
173-
if(mediaPlayer != null){
174-
175-
}
176-
}
177-
178171
@Override
179172
public void onCompletion(MediaPlayer mediaPlayer) {
180173
stopPlaying();
181174
}
182175

183176
private void selectAudio() {
177+
stopRecording();
184178
setResult(RESULT_OK);
185179
finish();
186180
}
@@ -191,16 +185,16 @@ public void toggleRecording(View v) {
191185
@Override
192186
public void run() {
193187
if (isRecording) {
194-
stopRecording();
188+
pauseRecording();
195189
} else {
196-
startRecording();
190+
resumeRecording();
197191
}
198192
}
199193
});
200194
}
201195

202196
public void togglePlaying(View v){
203-
stopRecording();
197+
pauseRecording();
204198
Util.wait(100, new Runnable() {
205199
@Override
206200
public void run() {
@@ -217,44 +211,48 @@ public void restartRecording(View v){
217211
stopRecording();
218212
stopPlaying();
219213
saveMenuItem.setVisible(false);
214+
statusView.setVisibility(View.INVISIBLE);
220215
restartView.setVisibility(View.INVISIBLE);
221216
playView.setVisibility(View.INVISIBLE);
222217
recordView.setImageResource(R.drawable.aar_ic_rec);
223218
timerView.setText("00:00:00");
224-
secondsElapsed = 0;
219+
recorderSecondsElapsed = 0;
220+
playerSecondsElapsed = 0;
225221
}
226222

227-
private void startRecording() {
223+
private void resumeRecording() {
228224
isRecording = true;
229225
saveMenuItem.setVisible(false);
230-
timerView.setText("00:00:00");
231226
statusView.setText(R.string.aar_recording);
232227
statusView.setVisibility(View.VISIBLE);
233228
restartView.setVisibility(View.INVISIBLE);
234229
playView.setVisibility(View.INVISIBLE);
235-
recordView.setImageResource(R.drawable.aar_ic_stop);
230+
recordView.setImageResource(R.drawable.aar_ic_pause);
236231
playView.setImageResource(R.drawable.aar_ic_play);
237232

238233
visualizerHandler = new VisualizerHandler();
239234
visualizerView.linkTo(visualizerHandler);
240235

241-
recorder = OmRecorder.wav(
242-
new PullTransport.Default(Util.getMic(), AudioRecorderActivity.this),
243-
new File(filePath));
244-
recorder.startRecording();
236+
if(recorder == null) {
237+
timerView.setText("00:00:00");
238+
239+
recorder = OmRecorder.wav(
240+
new PullTransport.Default(Util.getMic(), AudioRecorderActivity.this),
241+
new File(filePath));
242+
}
243+
recorder.resumeRecording();
245244

246245
startTimer();
247246
}
248247

249-
private void stopRecording() {
248+
private void pauseRecording() {
250249
isRecording = false;
251250
if(!isFinishing()) {
252251
saveMenuItem.setVisible(true);
253252
}
254-
statusView.setText("");
255-
statusView.setVisibility(View.INVISIBLE);
256-
// TODO pause and restart recording before showing this button
257-
// restartView.setVisibility(View.VISIBLE);
253+
statusView.setText(R.string.aar_paused);
254+
statusView.setVisibility(View.VISIBLE);
255+
restartView.setVisibility(View.VISIBLE);
258256
playView.setVisibility(View.VISIBLE);
259257
recordView.setImageResource(R.drawable.aar_ic_rec);
260258
playView.setImageResource(R.drawable.aar_ic_play);
@@ -265,16 +263,25 @@ private void stopRecording() {
265263
visualizerHandler.stop();
266264
}
267265

266+
if (recorder != null) {
267+
recorder.pauseRecording();
268+
}
269+
270+
stopTimer();
271+
}
272+
273+
private void stopRecording(){
274+
recorderSecondsElapsed = 0;
268275
if (recorder != null) {
269276
recorder.stopRecording();
270277
recorder = null;
271278
}
272-
273279
stopTimer();
274280
}
275281

276282
private void startPlaying(){
277283
try {
284+
stopRecording();
278285
player = new MediaPlayer();
279286
player.setDataSource(filePath);
280287
player.prepare();
@@ -291,8 +298,9 @@ public void run() {
291298
timerView.setText("00:00:00");
292299
statusView.setText(R.string.aar_playing);
293300
statusView.setVisibility(View.VISIBLE);
294-
playView.setImageResource(R.drawable.aar_ic_pause);
301+
playView.setImageResource(R.drawable.aar_ic_stop);
295302

303+
playerSecondsElapsed = 0;
296304
startTimer();
297305
} catch (Exception e){
298306
e.printStackTrace();
@@ -308,7 +316,6 @@ private void stopPlaying(){
308316
try {
309317
player.stop();
310318
player.reset();
311-
player.release();
312319
} catch (Exception e){ }
313320
}
314321

@@ -325,7 +332,6 @@ private boolean isPlaying(){
325332

326333
private void startTimer(){
327334
stopTimer();
328-
secondsElapsed = 0;
329335
timer = new Timer();
330336
timer.scheduleAtFixedRate(new TimerTask() {
331337
@Override
@@ -339,18 +345,22 @@ private void stopTimer(){
339345
if (timer != null) {
340346
timer.cancel();
341347
timer.purge();
348+
timer = null;
342349
}
343350
}
344351

345352
private void updateTimer() {
346-
if(isRecording || isPlaying()) {
347-
runOnUiThread(new Runnable() {
348-
@Override
349-
public void run() {
350-
secondsElapsed++;
351-
timerView.setText(Util.formatSeconds(secondsElapsed));
353+
runOnUiThread(new Runnable() {
354+
@Override
355+
public void run() {
356+
if(isRecording) {
357+
recorderSecondsElapsed++;
358+
timerView.setText(Util.formatSeconds(recorderSecondsElapsed));
359+
} else if(isPlaying()){
360+
playerSecondsElapsed++;
361+
timerView.setText(Util.formatSeconds(playerSecondsElapsed));
352362
}
353-
});
354-
}
363+
}
364+
});
355365
}
356366
}
Collapse file

‎lib/src/main/res/values-pt/strings.xml‎

Copy file name to clipboard
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<resources>
2-
<string name="save">Savar</string>
3-
<string name="recording">Gravando</string>
4-
<string name="playing">Reproduzindo</string>
2+
<string name="aar_save">Savar</string>
3+
<string name="aar_paused">Pausado</string>
4+
<string name="aar_recording">Gravando</string>
5+
<string name="aar_playing">Reproduzindo</string>
56
</resources>
Collapse file

‎lib/src/main/res/values/strings.xml‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<resources>
22
<string name="app_name" translatable="false">AndroidAudioRecorder</string>
33
<string name="aar_save">Save</string>
4+
<string name="aar_paused">Paused</string>
45
<string name="aar_recording">Recording</string>
56
<string name="aar_playing">Playing</string>
67
</resources>
Collapse file

‎screenshots.png‎

Copy file name to clipboard
-42.3 KB
  • Display the source diff
  • Display the rich diff
Loading

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.