@Override public void onClick(View v) { if (LCIMAudioHelper.getInstance().isPlaying() == true && LCIMAudioHelper.getInstance().getAudioPath().equals(path)) { LCIMAudioHelper.getInstance().pausePlayer(); stopRecordAnimation(); } else { LCIMAudioHelper.getInstance().playAudio(path); LCIMAudioHelper.getInstance() .addFinishCallback( new LCIMAudioHelper.AudioFinishCallback() { @Override public void onFinish() { stopRecordAnimation(); } }); startRecordAnimation(); } }
/** * 设置语音文件位置 * * @param path */ public void setPath(String path) { this.path = path; stopRecordAnimation(); if (isPlaying()) { LCIMAudioHelper.getInstance() .addFinishCallback( new LCIMAudioHelper.AudioFinishCallback() { @Override public void onFinish() { stopRecordAnimation(); } }); startRecordAnimation(); } }
private boolean isPlaying() { return LCIMAudioHelper.getInstance().isPlaying() == true && LCIMAudioHelper.getInstance().getAudioPath().equals(path); }