/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.micode.soundrecorder;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.media.AudioManager;
import android.media.MediaRecorder;
import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
public class SoundRecorder extends Activity implements Button.OnClickListener,
Recorder.OnStateChangedListener {
private static final String TAG = "SoundRecorder";
private static final String RECORDER_STATE_KEY = "recorder_state";
private static final String SAMPLE_INTERRUPTED_KEY = "sample_interrupted";
private static final String MAX_FILE_SIZE_KEY = "max_file_size";
private static final String AUDIO_3GPP = "audio/3gpp";
private static final String AUDIO_AMR = "audio/amr";
private static final String AUDIO_ANY = "audio/*";
private static final String ANY_ANY = "*/*";
private static final String FILE_EXTENSION_AMR = ".amr";
private static final String FILE_EXTENSION_3GPP = ".3gpp";
public static final int BITRATE_AMR = 2 * 1024 * 8; // bits/sec
public static final int BITRATE_3GPP = 20 * 1024 * 8; // bits/sec
private static final int SEEK_BAR_MAX = 10000;
private static final long WHEEL_SPEED_NORMAL = 1800;
private static final long WHEEL_SPEED_FAST = 300;
private static final long WHEEL_SPEED_SUPER_FAST = 100;
private static final long SMALL_WHEEL_SPEED_NORMAL = 900;
private static final long SMALL_WHEEL_SPEED_FAST = 200;
private static final long SMALL_WHEEL_SPEED_SUPER_FAST = 200;
private String mRequestedType = AUDIO_ANY;
private boolean mCanRequestChanged = false;
private Recorder mRecorder;
private RecorderReceiver mReceiver;
private boolean mSampleInterrupted = false;
private boolean mShowFinishButton = false;
private String mErrorUiMessage = null; // Some error messages are displayed
// in the UI, not a dialog. This
// happens when a recording
// is interrupted for some reason.
private long mMaxFileSize = -1; // can be specified in the intent
private RemainingTimeCalculator mRemainingTimeCalculator;
private String mTimerFormat;
private SoundPool mSoundPool;
private int mPlaySound;
private int mPauseSound;
private HashSet<String> mSavedRecord;
private long mLastClickTime;
private int mLastButtonId;
private final Handler mHandler = new Handler();
private Runnable mUpdateTimer = new Runnable() {
public void run() {
if (!mStopUiUpdate) {
updateTimerView();
}
}
};
private Runnable mUpdateSeekBar = new Runnable() {
@Override
public void run() {
if (!mStopUiUpdate) {
updateSeekBar();
}
}
};
private Runnable mUpdateVUMetur = new Runnable() {
@Override
public void run() {
if (!mStopUiUpdate) {
updateVUMeterView();
}
}
};
private ImageButton mNewButton;
private ImageButton mFinishButton;
private ImageButton mRecordButton;
private ImageButton mStopButton;
private ImageButton mPlayButton;
private ImageButton mPauseButton;
private ImageButton mDeleteButton;
private WheelImageView mWheelLeft;
private WheelImageView mWheelRight;
private WheelImageView mSmallWheelLeft;
private WheelImageView mSmallWheelRight;
private RecordNameEditText mFileNameEditText;
private LinearLayout mTimerLayout;
private LinearLayout mVUMeterLayout;
private LinearLayout mSeekBarLayout;
private TextView mStartTime;
private TextView mTotalTime;
private SeekBar mPlaySeekBar;
private BroadcastReceiver mSDCardMountEventReceiver = null;
private int mPreviousVUMax;
private boolean mStopUiUpdate;
@Override
public void onCreate(Bundle icycle) {
super.onCreate(icycle);
initInternalState(getIntent());
setContentView(R.layout.main);
mRecorder = new Recorder(this);
mRecorder.setOnStateChangedListener(this);
mReceiver = new RecorderReceiver();
mRemainingTimeCalculator = new RemainingTimeCalculator();
mSavedRecord = new HashSet<String>();
initResourceRefs();
setResult(RESULT_CANCELED);
registerExternalStorageListener();
if (icycle != null) {
Bundle recorderState = icycle.getBundle(RECORDER_STATE_KEY);
if (recorderState != null) {
mRecorder.restoreState(recorderState);
mSampleInterrupted = recorderState.getBoolean(SAMPLE_INTERRUPTED_KEY, false);
mMaxFileSize = recorderState.getLong(MAX_FILE_SIZE_KEY, -1);
}
}
setVolumeControlStream(AudioManager.STREAM_MUSIC);
if (mShowFinishButton) {
// reset state if it is a recording request
mRecorder.reset();
resetFileNameEditText();
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
boolean preShowFinishButton = mShowFinishButton;
initInternalState(intent);
if (mShowFinishButton || preShowFinishButton != mShowFinishButton) {
// reset state if it is a recording request or state is changed
mRecorder.reset();
resetFileNameEditText();
}
}
private void initInternalState(Intent i) {
mRequestedType = AUDIO_ANY;
mShowFinishButton = false;
if (i != null) {
String s = i.getType();
if (AUDIO_AMR.equals(s) || AUDIO_3GPP.equals(s) || AUDIO_ANY.equals(s)
|| ANY_ANY.equals(s)) {
mRequestedType = s;
mShowFinishButton = true;
} else if (s != null) {
// we only support amr and 3gpp formats right now
setResult(RESULT_CANCELED);
finish();
return;
}
final String EXTRA_MAX_BYTES = android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES;
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源内容:项目全套源码+完整文档 源码说明: 全部项目源码都是经过测试校正后百分百成功运行。 SpringBoot 毕业设计,SpringBoot 课程设计,基于SpringBoot+Vue开发的,含有代码注释,新手也可看懂。ssm整合开发,小程序毕业设计、期末大作业、课程设计、高分必看,下载下来,简单部署,就可以使用。 包含:项目源码、数据库脚本、软件工具等,该项目可以作为毕设、课程设计使用,前后端代码都在里面。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 项目都经过严格调试,确保可以运行! 1. 技术组成 前端:Vue/JSP/React/HTML+JS+CSS/ASP 后台框架代码:java/c/c++/php/VB/lun/Andorid/Python 开发环境:idea 数据库:MySql(建议用 5.7,8.0 有时候会有坑) 部署环境:Tomcat(建议用 7.x 或者 8.x b版本),maven
资源推荐
资源详情
资源评论
收起资源包目录
[Android应用源码]MIUI录音机.rar (177个子文件)
resources.ap_ 382KB
SoundRecorder.apk 413KB
SoundRecorder.class 29KB
RecorderService.class 11KB
Recorder.class 8KB
RecordNameEditText.class 4KB
RemainingTimeCalculator.class 2KB
R$drawable.class 2KB
WheelImageView.class 2KB
SoundRecorder$4.class 2KB
R$string.class 2KB
SeamlessAnimation.class 2KB
SoundRecorderPreferenceActivity.class 2KB
SoundRecorder$RecorderReceiver.class 2KB
R$id.class 1KB
SoundRecorder$5.class 1KB
SoundRecorder$10.class 1KB
SoundRecorder$6.class 1KB
SoundRecorder$9.class 973B
SoundRecorder$7.class 959B
SoundRecorder$8.class 926B
RecorderService$2.class 848B
RecorderService$1.class 816B
SoundRecorder$2.class 773B
SoundRecorder$1.class 773B
SoundRecorder$3.class 773B
R.class 677B
R$array.class 650B
R$layout.class 493B
R$xml.class 410B
R$attr.class 358B
BuildConfig.class 357B
RecordNameEditText$OnNameChangeListener.class 314B
Recorder$OnStateChangedListener.class 290B
.classpath 475B
config 255B
classes.dex 63KB
FETCH_HEAD 118B
.gitignore 135B
HEAD 124B
HEAD 23B
pack-d8a2a3003c41194dcbb432857eda5a41920bd1c2.idx 4KB
index 7KB
annotations-06d845c7c56427b837a7ef31a3a7a9b9.jar 943B
SoundRecorder.java 47KB
RecorderService.java 14KB
Recorder.java 10KB
R.java 10KB
RemainingTimeCalculator.java 5KB
RecordNameEditText.java 5KB
WheelImageView.java 3KB
SeamlessAnimation.java 2KB
SoundRecorderPreferenceActivity.java 2KB
BuildConfig.java 166B
master 138B
master 124B
master 41B
master 41B
NOTICE 10KB
pack-d8a2a3003c41194dcbb432857eda5a41920bd1c2.pack 453KB
tape_bottom.png 103KB
tape_bottom.png 100KB
background_key.png 64KB
background_key.png 62KB
tape_top.png 43KB
tape_top.png 40KB
background.png 32KB
background.png 29KB
wheel_left.png 19KB
wheel_right.png 19KB
wheel_left.png 16KB
wheel_right.png 16KB
ic_launcher_soundrecorder.png 10KB
btn_finish_pressed.9.png 8KB
btn_new_pressed.9.png 8KB
btn_record_pressed.9.png 8KB
ic_launcher_soundrecorder.png 8KB
btn_play_pressed.9.png 7KB
btn_delete_pressed.9.png 7KB
btn_stop_pressed.9.png 7KB
btn_pause_pressed.9.png 7KB
btn_finish_pressed.9.png 6KB
btn_new_pressed.9.png 6KB
btn_finish_normal.9.png 6KB
btn_new_normal.9.png 6KB
btn_finish_disabled.9.png 6KB
btn_new_disabled.9.png 6KB
wheel_small_right.png 5KB
btn_record_pressed.9.png 5KB
wheel_small_left.png 5KB
btn_record_normal.9.png 5KB
btn_play_pressed.9.png 5KB
btn_play_normal.9.png 5KB
btn_delete_pressed.9.png 5KB
btn_delete_normal.9.png 5KB
number_8.png 5KB
btn_delete_disabled.9.png 5KB
number_9.png 5KB
number_0.png 5KB
number_6.png 4KB
共 177 条
- 1
- 2
资源评论
程序员小马软件开发定制
- 粉丝: 4924
- 资源: 2246
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功