Condividi tramite


MediaRecorder.SetMaxDuration(Int32) Method

Definition

Sets the maximum duration (in ms) of the recording session.

[Android.Runtime.Register("setMaxDuration", "(I)V", "GetSetMaxDuration_IHandler")]
public virtual void SetMaxDuration (int max_duration_ms);
[<Android.Runtime.Register("setMaxDuration", "(I)V", "GetSetMaxDuration_IHandler")>]
abstract member SetMaxDuration : int -> unit
override this.SetMaxDuration : int -> unit

Parameters

max_duration_ms
Int32

the maximum duration in ms (if zero or negative, disables the duration limit)

Attributes

Exceptions

Remarks

Sets the maximum duration (in ms) of the recording session. Call this after setOutputFormat() but before prepare(). After recording reaches the specified duration, a notification will be sent to the android.media.MediaRecorder.OnInfoListener with a "what" code of #MEDIA_RECORDER_INFO_MAX_DURATION_REACHED and recording will be stopped. Stopping happens asynchronously, there is no guarantee that the recorder will have stopped by the time the listener is notified.

When using MPEG-4 container (#setOutputFormat(int) with OutputFormat#MPEG_4), it is recommended to set maximum duration that fits the use case. Setting a larger than required duration may result in a larger than needed output file because of space reserved for MOOV box expecting large movie data in this recording session. Unused space of MOOV box is turned into FREE box in the output file.

Java documentation for android.media.MediaRecorder.setMaxDuration(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to