A simple themable & integrable audio player library for Android.
MIT License
237
stars
78
forks
source link
When tapped or clicked on the mic icon once called onLessThanSecond() and then trying to record next time not working until app is killed and opened . Getting error at stop(); Below is my implementation code #23
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(CreateNewReminderActivity.this);
LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.pop_up_record_audio, null);
builder.setView(dialogView);
final android.support.v7.app.AlertDialog dialog = builder.create();
ImageView cancel = (ImageView) dialogView.findViewById(R.id.declineButton);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Dismiss the alert dialog
dialog.cancel();
// Set the main layout background color red
}
});
RecordView recordView = (RecordView) dialogView.findViewById(R.id.record_view);
final RecordButton recordButton = (RecordButton) dialogView.findViewById(R.id.record_button);
Button btnChangeOnclick = (Button) dialogView.findViewById(R.id.btn_change_onclick);
//IMPORTANT
recordButton.setRecordView(recordView);
// if you want to click the button (in case if you want to make the record button a Send Button for example..)
// recordButton.setListenForRecord(false);
btnChangeOnclick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (recordButton.isListenForRecord()) {
recordButton.setListenForRecord(false);
//ListenForRecord must be false ,otherwise onClick will not be called
recordButton.setOnRecordClickListener(new OnRecordClickListener() {
@Override
public void onClick(View v) {
// Toast.makeText(CreateNewReminderActivity.this, "Hold on the mic to record audio", Toast.LENGTH_SHORT).show();
// dialog.dismiss();
Log.d("RecordButton" + " RECORD BUTTON CLICKED");
}
});
//Cancel Bounds is when the Slide To Cancel text gets before the timer . default is 25
recordView.setCancelBounds(30);
recordView.setSmallMicColor(Color.parseColor("#c2185b"));
//prevent recording under one Second
recordView.setLessThanSecondAllowed(false);
recordView.setSlideToCancelText("Slide To Cancel");
recordView.setCustomSounds(R.raw.record_start, R.raw.record_finished, 0);
recordView.setOnRecordListener(new OnRecordListener() {
@Override
public void onStart() {
Log.d("RecordView" + " onStart");
Log.d("RecordView" + " onCancel");
}
@Override
public void onFinish(long recordTime) {
String time = getHumanTimeText(recordTime);
// Toast.makeText(CreateNewReminderActivity.this, "onFinishRecord - Recorded Time is: " + time, Toast.LENGTH_SHORT).show();
Log.d("RecordView" + " onFinish");
Log.d("RecordTime "+ time);
private void showAudioRecordPopUp() {
// recordButton.setListenForRecord(false);
// Toast.makeText(CreateNewReminderActivity.this, "onClickEnabled", Toast.LENGTH_SHORT).show(); } else { recordButton.setListenForRecord(true); // Toast.makeText(CreateNewReminderActivity.this, "onClickDisabled", Toast.LENGTH_SHORT).show(); } } });
// Toast.makeText(CreateNewReminderActivity.this, "Hold on the mic to record audio", Toast.LENGTH_SHORT).show(); // dialog.dismiss(); Log.d("RecordButton" + " RECORD BUTTON CLICKED"); } });
// Toast.makeText(CreateNewReminderActivity.this, "OnStartRecord", Toast.LENGTH_SHORT).show();
// Toast.makeText(CreateNewReminderActivity.this, "onCancel", Toast.LENGTH_SHORT).show();
// Toast.makeText(CreateNewReminderActivity.this, "onFinishRecord - Recorded Time is: " + time, Toast.LENGTH_SHORT).show(); Log.d("RecordView" + " onFinish"); Log.d("RecordTime "+ time);