# MediaStoreOutputOptions.Builder

Artifact: [androidx.camera:camera-video](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/video/MediaStoreOutputOptions.java+class:androidx.camera.video.MediaStoreOutputOptions.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

*** ** * ** ***


```
class MediaStoreOutputOptions.Builder
```

<br />

*** ** * ** ***

The builder of the `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions` object.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder#Builder(android.content.ContentResolver,android.net.Uri)(contentResolver: https://developer.android.com/reference/android/content/ContentResolver.html, collectionUri: https://developer.android.com/reference/android/net/Uri.html)` Creates a builder of the `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions` with media store options. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions` | `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder#build()()` Builds the `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions` instance. |
| `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder` | `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder#setContentValues(android.content.ContentValues)(contentValues: https://developer.android.com/reference/android/content/ContentValues.html)` Sets the content values to be included in the created video row. |
| `B` | `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder#setDurationLimitMillis(long)(durationLimitMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the limit for the video duration in milliseconds. |
| `B` | `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder#setFileSizeLimit(long)(fileSizeLimitBytes: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the limit for the file length in bytes. |
| `B` | `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder#setLocation(android.location.Location)(location: https://developer.android.com/reference/android/location/Location.html?)` Sets a `https://developer.android.com/reference/android/location/Location.html` object representing a geographic location where the video was recorded. |

## Public constructors

### Builder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
Builder(contentResolver: ContentResolver, collectionUri: Uri)
```

Creates a builder of the `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions` with media store options.

The ContentResolver can be obtained by app `https://developer.android.com/reference/android/content/Context.html#getContentResolver()` and is used to access to MediaStore.

`https://developer.android.com/reference/android/provider/MediaStore.html` 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 `https://developer.android.com/reference/android/provider/MediaStore.Video.Media.html#EXTERNAL_CONTENT_URI`. `https://developer.android.com/reference/android/provider/MediaStore.Video.Media.html#getContentUri(java.lang.String)` can also be used to query different storage volumes. For more information, read [Access media files from shared storage](https://developer.android.com/training/data-storage/shared/media) developer guide.

When recording a video, a corresponding video row will be created in the input collection, and the content values set by `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions.Builder#setContentValues(android.content.ContentValues)` will also be written to this row.

| Parameters |
|---|---|
| `contentResolver: https://developer.android.com/reference/android/content/ContentResolver.html` | the ContentResolver instance. |
| `collectionUri: https://developer.android.com/reference/android/net/Uri.html` | the URI of the collection to insert into. |

## Public functions

### build

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
fun build(): MediaStoreOutputOptions
```

Builds the `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions` instance.

### setContentValues

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
fun setContentValues(contentValues: ContentValues): MediaStoreOutputOptions.Builder
```

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 `https://developer.android.com/reference/android/provider/MediaStore.MediaColumns.html` and `https://developer.android.com/reference/android/provider/MediaStore.Video.VideoColumns.html`. 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 `https://developer.android.com/reference/kotlin/androidx/camera/video/MediaStoreOutputOptions#EMPTY_CONTENT_VALUES()`.

| Parameters |
|---|---|
| `contentValues: https://developer.android.com/reference/android/content/ContentValues.html` | the content values to be inserted. |

### setDurationLimitMillis

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
fun setDurationLimitMillis(durationLimitMillis: @IntRange(from = 0) Long): B
```

Sets the limit for the video duration in milliseconds.

When used to generate recording with `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder`, if the specified duration limit is reached while the recording is being recorded, the recording will be finalized with `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize#ERROR_DURATION_LIMIT_REACHED()`.

If not set or set with zero, the duration will be `https://developer.android.com/reference/kotlin/androidx/camera/video/OutputOptions#DURATION_UNLIMITED()`. If set with a negative value, an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` will be thrown.

| Parameters |
|---|---|
| `durationLimitMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the video duration limit in milliseconds. |

| Returns |
|---|---|
| `B` | this Builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the specified duration limit is negative. |

### setFileSizeLimit

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
fun setFileSizeLimit(fileSizeLimitBytes: @IntRange(from = 0) Long): B
```

Sets the limit for the file length in bytes.

When used with `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder` to generate recording, if the specified file size limit is reached while the recording is being recorded, the recording will be finalized with `https://developer.android.com/reference/kotlin/androidx/camera/video/VideoRecordEvent.Finalize#ERROR_FILE_SIZE_LIMIT_REACHED()`.

If not set or set with zero, the file size will be `https://developer.android.com/reference/kotlin/androidx/camera/video/OutputOptions#FILE_SIZE_UNLIMITED()`. If set with a negative value, an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` will be thrown.

| Parameters |
|---|---|
| `fileSizeLimitBytes: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | the file size limit in bytes. |

| Returns |
|---|---|
| `B` | this Builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the specified file size limit is negative. |

### setLocation

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/camera#1.2.0)

```
fun setLocation(location: Location?): B
```

Sets a `https://developer.android.com/reference/android/location/Location.html` object representing a geographic location where the video was recorded.

When used with `https://developer.android.com/reference/kotlin/androidx/camera/video/Recorder`, only the latitude and longitude from the `https://developer.android.com/reference/android/location/Location.html` are stored in the udta box if the output format is MP4, and are ignored for other formats. Other location data (such as altitude) is not stored. The geographic location is stored according to the ISO-6709 standard.

If `null`, no location information will be saved with the video. Default value is `null`.

| Parameters |
|---|---|
| `location: https://developer.android.com/reference/android/location/Location.html?` | the location object, or `null` if no location should be saved. |

| Returns |
|---|---|
| `B` | this Builder. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the latitude of the location is not in the range `[-90, 90]` or the longitude of the location is not in the range `[-180, 180]`. |