Java Code Examples for android.media.MediaRecorder#MEDIA_RECORDER_INFO_MAX_DURATION_REACHED

The following examples show how to use android.media.MediaRecorder#MEDIA_RECORDER_INFO_MAX_DURATION_REACHED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VideoModule.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onInfo(MediaRecorder mr, int what, int extra)
{
    if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED)
    {
        if (mMediaRecorderRecording)
        {
            onStopVideoRecording();
        }
    } else if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED)
    {
        if (mMediaRecorderRecording)
        {
            onStopVideoRecording();
        }

        // Show the toast.
        Toast.makeText(mActivity, R.string.video_reach_size_limit,
                Toast.LENGTH_LONG).show();
    }
}
 
Example 2
Source File: CameraController.java    From KrGallery with GNU General Public License v2.0 6 votes vote down vote up
@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;
                    }
                }
            });
        }
    }
}
 
Example 3
Source File: VideoRecorder.java    From VideoCamera with Apache License 2.0 6 votes vote down vote up
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
    switch (what) {
        case MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN:
            // NOP
            break;
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED:
            CLog.d(CLog.RECORDER, "MediaRecorder max duration reached");
            stopRecording("Capture stopped - Max duration reached");
            break;
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:
            CLog.d(CLog.RECORDER, "MediaRecorder max filesize reached");
            stopRecording("Capture stopped - Max file size reached");
            break;
        default:
            break;
    }
}
 
Example 4
Source File: Utils.java    From ChatMessagesAdapter-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static String parseCode(int what) {
    String msg = null;
    switch (what) {
        case MediaRecorder.MEDIA_RECORDER_ERROR_UNKNOWN:
            msg = "MEDIA_RECORDER_ERROR_INFO_UNKNOWN";
            break;
        case MediaRecorder.MEDIA_ERROR_SERVER_DIED:
            msg = "MEDIA_ERROR_SERVER_DIED";
            break;
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED:
            msg = "MEDIA_RECORDER_INFO_MAX_DURATION_REACHED";
            break;
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:
            msg = "MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED";
            break;
        case MEDIA_RECORDING_IS_IN_PROGRESS:
            msg = "MEDIA_RECORDING_IS_IN_PROGRESS";
            break;
        default:
            msg = "UNKNOWN";
            break;
    }
    return msg;
}
 
Example 5
Source File: VideoRecorder.java    From LandscapeVideoCamera with Apache License 2.0 6 votes vote down vote up
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
    switch (what) {
        case MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN:
            // NOP
            break;
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED:
            CLog.d(CLog.RECORDER, "MediaRecorder max duration reached");
            stopRecording("Capture stopped - Max duration reached");
            break;
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:
            CLog.d(CLog.RECORDER, "MediaRecorder max filesize reached");
            stopRecording("Capture stopped - Max file size reached");
            break;
        default:
            break;
    }
}
 
Example 6
Source File: CameraController.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@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) {
            finishRecordingVideo();
        }
    }
}
 
Example 7
Source File: AttachmentPopupFragment.java    From weMessage with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
    if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED){
        isRecording = false;
        getAudioRecorder().stop();
        getAudioRecorder().release();
        audioRecorder = null;

        attachmentPopupAudioButton.setSelected(false);
        attachmentPopupAudioButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_trash_exit, 0, 0);
        attachmentPopupAudioButton.setTextColor(Color.BLACK);
        attachmentPopupAudioButton.setText(getString(R.string.delete_audio_recording));
        attachmentPopupAudioButton.setTextSize(12);
    }
}
 
Example 8
Source File: CameraController.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@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) {
            finishRecordingVideo();
        }
    }
}
 
Example 9
Source File: CameraActivity_OldAPI.java    From microbit with Apache License 2.0 5 votes vote down vote up
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
    switch(what) {
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED:
        case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:
            playAudioPresenter.setInternalPathForPlay(InternalPaths.MAX_VIDEO_RECORDED);
            playAudioPresenter.start();
            stopRecording();
            break;
        case MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN:
            logi("Error in media recorder - What = " + what + " extra = " + extra);
            stopRecording();
            break;
    }
}
 
Example 10
Source File: SoundRecorder.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public void onInfo(MediaRecorder affectedRecorder, int what, int extra) {
  if (controller == null || affectedRecorder != controller.recorder) {
    Log.w(TAG, "onInfo called with wrong recorder. Ignoring.");
    return;
  }
  switch (what) {
  case MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED:
    form.dispatchErrorOccurredEvent(this, "recording",
        ErrorMessages.ERROR_SOUND_RECORDER_MAX_DURATION_REACHED);
    break;
  case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:
    form.dispatchErrorOccurredEvent(this, "recording",
        ErrorMessages.ERROR_SOUND_RECORDER_MAX_FILESIZE_REACHED);
    break;
  case MediaRecorder.MEDIA_RECORDER_INFO_UNKNOWN:
    form.dispatchErrorOccurredEvent(this, "recording", ErrorMessages.ERROR_SOUND_RECORDER);
    break;
  default:
    // value of `what` is not valid, probably device-specific debugging. escape early to prevent
    // stoppage until we see an Android-defined error. See also:
    // http://stackoverflow.com/questions/25785420/mediarecorder-oninfolistener-giving-an-895
    return;
  }
  try {
    Log.i(TAG, "Recoverable condition while recording. Will attempt to stop normally.");
    controller.recorder.stop();
  } catch(IllegalStateException e) {
    Log.i(TAG, "SoundRecorder was not in a recording state.", e);
    form.dispatchErrorOccurredEventDialog(this, "Stop",
        ErrorMessages.ERROR_SOUND_RECORDER_ILLEGAL_STOP);
  } finally {
    controller = null;
    StoppedRecording();
  }
}
 
Example 11
Source File: BaseCameraManager.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void onInfo(MediaRecorder mediaRecorder, int what, int extra) {
    if (MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED == what) {
        onMaxDurationReached();
    } else if (MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED == what) {
        onMaxFileSizeReached();
    }
}
 
Example 12
Source File: BaseCameraManager.java    From sandriosCamera with MIT License 5 votes vote down vote up
@Override
public void onInfo(MediaRecorder mediaRecorder, int what, int extra) {
    if (MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED == what) {
        onMaxDurationReached();
    } else if (MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED == what) {
        onMaxFileSizeReached();
    }
}
 
Example 13
Source File: RecorderVideoActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
	EMLog.v("video", "onInfo");
	if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
		EMLog.v("video", "max duration reached");
		stopRecording();
		btn_switch.setVisibility(View.VISIBLE);
		chronometer.stop();
		btnStart.setVisibility(View.VISIBLE);
		btnStop.setVisibility(View.INVISIBLE);
		chronometer.stop();
		if (localPath == null) {
			return;
		}
		new AlertDialog.Builder(this)
				.setMessage("是否发送?")
				.setPositiveButton(R.string.ok,
						new DialogInterface.OnClickListener() {

							@Override
							public void onClick(DialogInterface arg0,
									int arg1) {
								arg0.dismiss();
								sendVideo(null);

							}
						}).setNegativeButton(R.string.cancel, null)
				.setCancelable(false).show();
	}

}
 
Example 14
Source File: CameraController.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@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) {
            finishRecordingVideo();
        }
    }
}
 
Example 15
Source File: CameraController.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@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) {
            finishRecordingVideo();
        }
    }
}