当前位置:编程学堂 > 小米录音机源码

小米录音机源码

  • 发布:2023-10-01 07:48

int ACTION_STOP_RECORDING = 2;公共最终静态 int ACTION_ENABLE_MONITOR_REMAIN_TIME = 3;公共最终静态 int ACTION_DISABLE_MONITOR_REMAIN_TIME = 4;公共最终静态字符串ACTION_PARAM_FORMAT =“格式”;公共最终静态字符串ACTION_PARAM_PATH =“路径”;公共最终静态字符串ACTION_PARAM_HIGH_QUALITY =“high_quality”;公共最终静态字符串ACTION_PARAM_MAX_FILE_SIZE =“max_file_size”;公共最终静态字符串RECORDER_SERVICE_BROADCAST_NAME =“com.android.soundrecorder.broadcast”;公共最终静态字符串RECORDER_SERVICE_BROADCAST_STATE =“is_recording”;公共最终静态字符串RECORDER_SERVICE_BROADCAST_ERROR =“error_code”;公共最终静态 int NOTIFICATION_ID = 62343234;私有静态 MediaRecorder mRecorder = null;私有静态字符串 mFilePath = null;私有静态长mStartTime=0;私人剩余时间计算器(); } 休息;默认值:                     中断; }             返回START_STICKY; }         return super.onStartCommand(intent, flags, startId); }       @Override     public void onDestroy() {         mTeleManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); if (mWakeLock.isHeld()) {             mWakeLock.release(); }         super.onDestroy(); }       @Override     public IBinder onBind(Intent intent) {         return null; }       @Override     public void onLowMemory() {         localStopRecording(); super.onLowMemory(); }       private void localStartRecording(int outputfileformat, String path, boolean highQuality,             long maxFileSize) {         if (mRecorder == null) {             mRemainingTimeCalculator.reset(); if (maxFileSize != -1) {                 mRemainingTimeCalculator.setFileSizundefinedcalStopRecording();返回; } else if (t <= 1800                 && mRemainingTimeCalculator.currentLowerLimit() != RemainingTimeCalculator.FILE_SIZE_LIMIT) {                          showLowStorageNotification((int) Math.ceil(t) / 60.0)); }           if (mRecorder != null && mNeedUpdateRemainingTime) {             mHandler.postDelayed(mUpdateRemainingTime, 500); }     }       public static boolean isRecording() {         return mRecorder != null; }       public static String getFilePath() {         return mFilePath; }       public static long getStartTime() {         return mStartTime; }       public static void startRecording(Context context, int outputfileformat, String path,             boolean highQuality, long maxFileSize) {         Intent intent = new Intent(context, RecorderService.class); Intent.putExtra(ACTION_NAME, ACTION_START_RECORDING);意图.putExtra(ACTION_PARAM_FORMAT,输出文件格式); Intent.putExtra(ACTION_PARAM_PATH, 路径); Intent.putExtra(ACTION_PARAM_HIGH_QUALITY, HighQuality); Intent.putExtra(ACTION_PARAM_MAX_FILE_SIZE, maxFileSize); context.startService(意图); }       public static void stopRecording(Context context) {         意图意图= new Intent(context, RecorderService.class); Intent.putExtra(ACTION_NAME, ACTION_STOP_RECORDING); context.startService(意图); }       public static int getMaxAmplitude() {         返回 mRecorder == null ? 0:mRecorder.getMaxAmplitude(); }       @Override     public void onError(MediaRecorder mr, int what, int extra) {         sendErrorBroadcast(Recorder.INTERNAL_ERROR); localStopRecording(); } } 下载地址:http://www.sychzs.cn/data/2089509

相关文章