Comments (4)
@rameshpaladugu can you post your full code? i think the problem is in you App Logic.
from recordview.
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);
// Toast.makeText(CreateNewReminderActivity.this, "onClickEnabled", Toast.LENGTH_SHORT).show();
} else {
recordButton.setListenForRecord(true);
// Toast.makeText(CreateNewReminderActivity.this, "onClickDisabled", Toast.LENGTH_SHORT).show();
}
}
});
//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");
// Toast.makeText(CreateNewReminderActivity.this, "OnStartRecord", Toast.LENGTH_SHORT).show();
recorder = new MediaRecorder();
//Start Recording..
try {
start();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
@Override
public void onCancel() {
// Toast.makeText(CreateNewReminderActivity.this, "onCancel", Toast.LENGTH_SHORT).show();
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);
//Stop Recording..
try {
stop();
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
}
dialog.dismiss();
}
@Override
public void onLessThanSecond() {
Toast.makeText(CreateNewReminderActivity.this, "Press and hold to record", Toast.LENGTH_SHORT).show();
Log.d("RecordView" + " onLessThanSecond");
}
});
recordView.setOnBasketAnimationEndListener(new OnBasketAnimationEnd() {
@Override
public void onAnimationEnd() {
Log.d("RecordView" + " Basket Animation Finished");
}
});
dialog.show();
}
private String getHumanTimeText(long milliseconds) {
return String.format("%02d:%02d",
TimeUnit.MILLISECONDS.toMinutes(milliseconds),
TimeUnit.MILLISECONDS.toSeconds(milliseconds) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds)));
}
public void start() throws IOException, IllegalStateException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
String currentDateandTime = sdf.format(new Date());
audioFileName = "Audio"+ currentDateandTime +".3gpp";
String path = Util.getSentDirectoryPath() + File.separator + audioFileName;
fileTemp = new File(Util.getSentDirectoryPath() + File.separator + audioFileName);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
}
public void stop() throws IOException, IllegalStateException {
if (recorder != null) {
recorder.stop();
recorder.release();
}
attachment_audio_section.removeAllViews();
audio_selected_section.setVisibility(View.VISIBLE);
isAudioFileSelected = true;
txt_audio_file_name.setText(audioFileName);
audio_file_remove.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (mAudioWife != null) {
// when done playing, release the resources
mAudioWife.release();
Log.d("@@@ AudioWife release player...");
}
File file = new File(Util.getSentDirectoryPath() + File.separator + audioFileName);
if (file.exists()) {
file.delete();
audioFileName = null;
isAudioFileSelected = false;
audio_selected_section.setVisibility(View.GONE);
attachment_audio_section.removeAllViews();
}
return false;
}
});
Uri mUri = Uri.fromFile(new File(Util.getSentDirectoryPath() + File.separator + audioFileName));
mAudioWife = AudioWife.getInstance();
mAudioWife.init(getApplicationContext(), mUri).useDefaultUi(attachment_audio_section, getLayoutInflater());
}
@Override
protected void onPause() {
super.onPause();
if (mAudioWife != null) {
// when done playing, release the resources
mAudioWife.release();
Log.d("@@@ AudioWife release player...");
}
}
from recordview.
Error : stop called in an invalid state: 0
from recordview.
@rameshpaladugu i am sorry, but i think this error is from MediaRecorder
or MediaPlayer
not from RecordView
.
from recordview.
Related Issues (20)
- Attempt to invoke interface method 'boolean com.devlomi.record_view.RecordPermissionHandler.isPermissionGranted()' on a null object reference HOT 1
- Recorded Audio HOT 1
- java.lang.NullPointerException: Attempt to invoke virtual method 'void com.devlomi.record_view.RecordView.onActionDown(com.devlomi.record_view.RecordButton, android.view.MotionEvent)' on a null object reference HOT 1
- if the phone's system font size is too large, the audio recording will be canceled as soon as it starts HOT 4
- Can't change the Growing animation scale-up value.
- how change cancel direction HOT 1
- recordview causes recyclerview to malfunction HOT 13
- How can I solve this error? HOT 3
- Seen Weird behaviour when using with epoxy recycler view and parent is constraint layout HOT 1
- Render problems from example app HOT 1
- Render problems from example app HOT 2
- just click on mic HOT 1
- Lock View Like Whatsapp HOT 1
- Listener for recording LOCKED event HOT 1
- UI allignment issue and swipe to cancel not working properly HOT 1
- Exception in MessageQueue callback: handleReceiveCallback java.lang.NullPointerException: Attempt to invoke virtual method 'void com.devlomi.record_view.RecordView.onActionDown(com.devlomi.record_view.RecordButton, android.view.MotionEvent)' on a null object reference HOT 1
- Plugin crashes when quickly tapping on the record button [Very rare] HOT 1
- No display HOT 3
- Lock feature implementation HOT 1
- Lock feature is not properly working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recordview.