Cambios en grabación para que no grabe sonido de iniciar

parent bbe38841
...@@ -16,6 +16,7 @@ import android.net.Uri; ...@@ -16,6 +16,7 @@ import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
...@@ -183,7 +184,7 @@ public class EditPictoActivity extends Activity { ...@@ -183,7 +184,7 @@ public class EditPictoActivity extends Activity {
textoTTotal.setText(tiempoTotal == 10 ? "00:00 | 00:" + tiempoTotal : "00:00 | 00:0" + tiempoTotal ); textoTTotal.setText(tiempoTotal == 10 ? "00:00 | 00:" + tiempoTotal : "00:00 | 00:0" + tiempoTotal );
barraReproducir.setMax(tiempoTotal); barraReproducir.setMax(tiempoTotal);
botonGrabar.PhidePressedRing(); botonGrabar.PhidePressedRing();
if(tiempoGrabado > 1) hayGrabacion = true ; if(tiempoGrabado >= 1) hayGrabacion = true ;
else hayGrabacion = false; else hayGrabacion = false;
reiniciarGrabacion(); reiniciarGrabacion();
} }
...@@ -486,15 +487,15 @@ public class EditPictoActivity extends Activity { ...@@ -486,15 +487,15 @@ public class EditPictoActivity extends Activity {
switch(event.getAction()){ switch(event.getAction()){
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
recordSoundOn.play(MediaActionSound.START_VIDEO_RECORDING); recordSoundOn.play(MediaActionSound.START_VIDEO_RECORDING);
try { //Para que no capture el sonido del sistema Handler handler = new Handler();
sleep(500); handler.postDelayed(new Runnable() {
} catch (InterruptedException e) { @Override
e.printStackTrace(); public void run() {
} gifRecord.setBackgroundResource(R.drawable.record_animation);
gifRecord.setBackgroundResource(R.drawable.record_animation); tareaGrabacion = (RecordTask) new RecordTask().execute(tiempoGrabado);
tareaGrabacion = (RecordTask) new RecordTask().execute(tiempoGrabado); startRecording();
startRecording(); }
}, 500); // 0.5s delay
return true; return true;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
tareaGrabacion.cancel(true); tareaGrabacion.cancel(true);
...@@ -529,11 +530,16 @@ public class EditPictoActivity extends Activity { ...@@ -529,11 +530,16 @@ public class EditPictoActivity extends Activity {
public void onClick(View v) { public void onClick(View v) {
borrado = true; borrado = true;
if(hayGrabacion){ if(hayGrabacion){
stopPlaying(); //stopPlaying();
layoutGrabacion.setVisibility(View.VISIBLE); layoutGrabacion.setVisibility(View.VISIBLE);
layoutPreview.setVisibility(View.GONE); layoutPreview.setVisibility(View.GONE);
hayGrabacion = false; hayGrabacion = false;
} }
File file = new File(previewAudioPath);
if(file.exists()){
file.delete();
}
/*previewAudioPath = null;*/
} }
}); });
...@@ -592,6 +598,7 @@ public class EditPictoActivity extends Activity { ...@@ -592,6 +598,7 @@ public class EditPictoActivity extends Activity {
} }
private void assignFileToPlayer(File audio){ private void assignFileToPlayer(File audio){
Log.i(DEBUG_MESSAGE,"Asignado: "+audio.getPath().toString());
mPlayer = new MediaPlayer(); mPlayer = new MediaPlayer();
try { try {
mPlayer.setDataSource(new FileInputStream(audio).getFD()); mPlayer.setDataSource(new FileInputStream(audio).getFD());
...@@ -607,6 +614,7 @@ public class EditPictoActivity extends Activity { ...@@ -607,6 +614,7 @@ public class EditPictoActivity extends Activity {
} }
private void startPlaying() { private void startPlaying() {
Log.i(DEBUG_MESSAGE,"reproduciendo..."+previewAudioPath);
try { try {
mPlayer.start(); mPlayer.start();
}catch (IllegalStateException e){ }catch (IllegalStateException e){
...@@ -664,21 +672,6 @@ public class EditPictoActivity extends Activity { ...@@ -664,21 +672,6 @@ public class EditPictoActivity extends Activity {
textoTTotal.setText("00:00 | 00:"+(tiempoTotal == 10 ? tiempoTotal : "0" + tiempoTotal)); textoTTotal.setText("00:00 | 00:"+(tiempoTotal == 10 ? tiempoTotal : "0" + tiempoTotal));
} }
/*@Override
public void onStop() {
super.onStop();
if (mRecorder != null) {
mRecorder.release();
mRecorder = null;
}
if (mPlayer!= null) {
mPlayer.release();
mPlayer = null;
}
}*/
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment