dimanche 10 juillet 2016

MediaRecorder.stop() hangs on Samsung Galaxy Camera

Calling stop() on my MediaRecorder hangs indefinitely on the Samsung Galaxy Camera. Placing this call in a separate thread does not help the problem either.

Logcat does not show any error messages. However, running this same app does not incur any problems on the Samsung Galaxy Nexus.

This is the code surrounding my call to stop:

View.OnClickListener captureListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (isRecording) {
            // stop recording and release camera
            mMediaRecorder.stop();
            releaseMediaRecorder(); // release the MediaRecorder object
            mCamera.lock();         // take camera access back from MediaRecorder
            // inform the user that recording has stopped
            captureButton.setText("Capture");
            isRecording = false;
        } else {
            // initialize video camera
            if (prepareVideoRecorder()) {
                // Camera is available and unlocked, MediaRecorder is prepared,
                // now you can start recording
                mMediaRecorder.start();
                // inform the user that recording has started
                captureButton.setText("Stop");
                isRecording = true;
            } else {
                // prepare didn't work, release the camera
                releaseMediaRecorder();
                // inform user
            }
        }
    }
};

Aucun commentaire:

Enregistrer un commentaire