当前位置: 首页>>代码示例>>Java>>正文


Java MediaRecorder.release方法代码示例

本文整理汇总了Java中android.media.MediaRecorder.release方法的典型用法代码示例。如果您正苦于以下问题:Java MediaRecorder.release方法的具体用法?Java MediaRecorder.release怎么用?Java MediaRecorder.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.MediaRecorder的用法示例。


在下文中一共展示了MediaRecorder.release方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: recordAudio

import android.media.MediaRecorder; //导入方法依赖的package包/类
static Audio recordAudio(UQI uqi, long duration) throws IOException {
    List<Integer> amplitudes = new ArrayList<>();

    MediaRecorder recorder = new MediaRecorder();
    recorder.setAudioSource(Globals.AudioConfig.audioSource);
    recorder.setOutputFormat(Globals.AudioConfig.outputFormat);
    recorder.setAudioEncoder(Globals.AudioConfig.audioEncoder);

    String audioPath = "temp/audio_" + TimeUtils.getTimeTag() + ".amr";
    File tempAudioFile = StorageUtils.getValidFile(uqi.getContext(), audioPath, false);
    recorder.setOutputFile(tempAudioFile.getAbsolutePath());

    recorder.prepare();
    recorder.start();   // Recording is now started

    long startTime = System.currentTimeMillis();
    while (true) {
        long currentTime = System.currentTimeMillis();
        if (currentTime - startTime > duration) {
            break;
        }
        amplitudes.add(recorder.getMaxAmplitude());
    }

    recorder.stop();
    recorder.reset();   // You can reuse the object by going back to setAudioSource() step
    recorder.release(); // Now the object cannot be reused

    AudioData audioData = AudioData.newTempRecord(tempAudioFile, amplitudes);

    return new Audio(startTime, audioData);
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:33,代码来源:AudioRecorder.java

示例2: startRecording

import android.media.MediaRecorder; //导入方法依赖的package包/类
public void startRecording() {
    if (this.paras.isTonghualuyin()) {
        try {
            mediaRecorder = new MediaRecorder();
            mediaRecorder.setAudioSource(4);
            mediaRecorder.setAudioSamplingRate(16000);
            mediaRecorder.setOutputFormat(3);
            mediaRecorder.setAudioEncoder(1);
            mediaRecorder.setOutputFile(this.file.getAbsolutePath());
            mediaRecorder.prepare();
            mediaRecorder.start();
            this.isRecord = true;
        } catch (Exception e) {
            this.isRecord = false;
            mediaRecorder.reset();
            mediaRecorder.release();
            mediaRecorder = null;
        }
    }
}
 
开发者ID:JamesLiAndroid,项目名称:AndroidKillerService,代码行数:21,代码来源:PhoneService.java

示例3: onInfo

import android.media.MediaRecorder; //导入方法依赖的package包/类
@Override
public void onInfo(MediaRecorder mediaRecorder, int what, int extra) {
    if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN) {
        MediaRecorder tempRecorder = recorder;
        recorder = null;
        if (tempRecorder != null) {
            tempRecorder.stop();
            tempRecorder.release();
        }
        if (onVideoTakeCallback != null) {
            final Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(recordedFile, MediaStore.Video.Thumbnails.MINI_KIND);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (onVideoTakeCallback != null) {
                        onVideoTakeCallback.onFinishVideoRecording(bitmap);
                        onVideoTakeCallback = null;
                    }
                }
            });
        }
    }
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:24,代码来源:CameraController.java

示例4: onInfo

import android.media.MediaRecorder; //导入方法依赖的package包/类
@Override
public void onInfo(MediaRecorder mediaRecorder, int what, int extra) {
    if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED || what == MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN) {
        MediaRecorder tempRecorder = recorder;
        recorder = null;
        if (tempRecorder != null) {
            tempRecorder.stop();
            tempRecorder.release();
        }
        final Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(recordedFile, MediaStore.Video.Thumbnails.MINI_KIND);
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public void run() {
                onVideoTakeCallback.onFinishVideoRecording(bitmap);
            }
        });
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:19,代码来源:CameraController.java

示例5: stopVideoRecording

import android.media.MediaRecorder; //导入方法依赖的package包/类
public void stopVideoRecording(CameraSession session, boolean abandon) {
    try {
        CameraInfo info = session.cameraInfo;
        Camera camera = info.camera;
        if (camera != null && recorder != null) {
            MediaRecorder tempRecorder = recorder;
            recorder = null;
            tempRecorder.stop();
            tempRecorder.release();
            camera.reconnect();
            camera.startPreview();
            session.stopVideoRecording();
        }
        if (!abandon) {
            final Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(recordedFile, MediaStore.Video.Thumbnails.MINI_KIND);
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    onVideoTakeCallback.onFinishVideoRecording(bitmap);
                }
            });
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:27,代码来源:CameraController.java

示例6: stopRecord

import android.media.MediaRecorder; //导入方法依赖的package包/类
public static void stopRecord(MediaRecorder recorder) {
    if (recorder != null) {
        recorder.stop();
        recorder.release();
        recorder = null;
    }
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:8,代码来源:RecoderManager.java

示例7: onRecordClick

import android.media.MediaRecorder; //导入方法依赖的package包/类
public void onRecordClick(View v) {
    if (!mRecording) {
        File f = new File(getExternalFilesDir(null), "recording.mp4");

        mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        mRecorder.setOutputFile(f.getAbsolutePath());
        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC_ELD);
        mRecorder.setAudioSamplingRate(48000);
        mRecorder.setAudioEncodingBitRate(96000);

        try {
            mRecorder.prepare();
        } catch (IOException e) {
            Log.e(TAG, "unable to prepare MediaRecorder");
            mRecorder = null;
            return;
        }

        mRecorder.start();
        mRecording = true;

        setState(STATE_RECORDING);
    } else {
        mRecorder.stop();
        mRecorder.release();
        mRecording = false;

        setState(STATE_IDLE);
    }
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:33,代码来源:MainActivity.java

示例8: onError

import android.media.MediaRecorder; //导入方法依赖的package包/类
public void onError(MediaRecorder mr, int what, int extra) 
{
    isRecording = false;
    mr.release();
}
 
开发者ID:mwsrc,项目名称:Dendroid-HTTP-RAT,代码行数:6,代码来源:RecordService.java


注:本文中的android.media.MediaRecorder.release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。