MediaStoreOutputOptions.Builder

public static final class MediaStoreOutputOptions.Builder
extends Object

java.lang.Object
   ↳ androidx.camera.video.MediaStoreOutputOptions.Builder


The builder of the MediaStoreOutputOptions object.

Summary

Public constructors

Builder(ContentResolver contentResolver, Uri collectionUri)

Creates a builder of the MediaStoreOutputOptions with media store options.

Public methods

MediaStoreOutputOptions build()

Builds the MediaStoreOutputOptions instance.

MediaStoreOutputOptions.Builder setContentValues(ContentValues contentValues)

Sets the content values to be included in the created video row.

MediaStoreOutputOptions.Builder setFileSizeLimit(long fileSizeLimitBytes)

Sets the limit for the file length in bytes.

Inherited methods

Public constructors

Builder

public Builder (ContentResolver contentResolver, 
                Uri collectionUri)

Creates a builder of the MediaStoreOutputOptions with media store options.

The ContentResolver can be obtained by app context and is used to access to MediaStore.

MediaStore class provides APIs to obtain the collection URI. A collection URI corresponds to a storage volume on the device shared storage. A common collection URI used to access the primary external storage is MediaStore.Video.Media.EXTERNAL_CONTENT_URI. MediaStore.Video.Media.getContentUri(String) can also be used to query different storage volumes. For more information, read Access media files from shared storage developer guide.

When recording a video, a corresponding video row will be created in the input collection, and the content values set by setContentValues(ContentValues) will also be written to this row.

Parameters
contentResolver ContentResolver: the ContentResolver instance.

collectionUri Uri: the URI of the collection to insert into.

Public methods

build

public MediaStoreOutputOptions build ()

Builds the MediaStoreOutputOptions instance.

Returns
MediaStoreOutputOptions

setContentValues

public MediaStoreOutputOptions.Builder setContentValues (ContentValues contentValues)

Sets the content values to be included in the created video row.

The content values is a set of key/value paris used to store the metadata of a video item. The keys are defined in MediaStore.MediaColumns and MediaStore.Video.VideoColumns. When recording a video, a corresponding video row will be created in the input collection, and this content values will also be written to this row. If a key is not defined in the MediaStore, the corresponding value will be ignored.

If not set, defaults to MediaStoreOutputOptions.EMPTY_CONTENT_VALUES.

Parameters
contentValues ContentValues: the content values to be inserted.

Returns
MediaStoreOutputOptions.Builder

setFileSizeLimit

public MediaStoreOutputOptions.Builder setFileSizeLimit (long fileSizeLimitBytes)

Sets the limit for the file length in bytes.

When used to generate recording, if the specified file size limit is reached while the recording is being recorded, the recording will be finalized with VideoRecordEvent.Finalize.ERROR_FILE_SIZE_LIMIT_REACHED.

If not set, defaults to OutputOptions.FILE_SIZE_UNLIMITED.

Parameters
fileSizeLimitBytes long

Returns
MediaStoreOutputOptions.Builder