欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  技术分享

Android MIUI小米录音机源码_Android录音源代码

程序员文章站 2022-03-01 13:34:08
...

众所周知、小米一向以UI精美著称、经典的小米录音机也不例外、录音的时候磁带的转动效果、停止录音的时候的倒带效果都是相当精致、录音完成后文件存储在内存卡的sound_recorder文件夹、所以硬性的要求存在内存卡才可以使用、项目的代码不多、注释合理、可以借鉴一下小米的编程语法与格式标准、看上代码风格还是非常好的

Android MIUI小米录音机源码_Android录音源代码


核心代码onCreate

@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();
	}
}


核心代码initInternalState

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;
		mMaxFileSize = i.getLongExtra(EXTRA_MAX_BYTES, -1);
	}

	if (AUDIO_ANY.equals(mRequestedType)) {
		mRequestedType = SoundRecorderPreferenceActivity
			.getRecordType(this);
	} else if (ANY_ANY.equals(mRequestedType)) {
		mRequestedType = AUDIO_3GPP;
	}
}


更多源代码、请下载导入Eclipse里面查看

源代码下载链接: http://dwtedx.com/download.html?bdkey=s/1dDwDv3N 密码: h4bi