# ThrowingSubtitleParserFactory

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/ThrowingSubtitleParserFactory.java+class:androidx.media3.test.utils.ThrowingSubtitleParserFactory)

*** ** * ** ***


```
@UnstableApi
public class ThrowingSubtitleParserFactory implements SubtitleParser.Factory
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory` for `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` instances that throw an exception on every call to `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser#parse(byte[],androidx.media3.extractor.text.SubtitleParser.OutputOptions,java.util.function.Consumer<androidx.media3.extractor.text.CuesWithTiming>)`.

It claims support for all subtitle formats (returns the result of `https://developer.android.com/reference/androidx/media3/common/MimeTypes#isText(java.lang.String)` from `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory#supportsFormat(androidx.media3.common.Format)`).

## Summary

| ### Constants |
|---|---|
| `static final int` | `@https://developer.android.com/reference/androidx/media3/common/Format.CueReplacementBehavior https://developer.android.com/reference/androidx/media3/test/utils/ThrowingSubtitleParserFactory#REPLACEMENT_BEHAVIOR() = 2` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ThrowingSubtitleParserFactory#ThrowingSubtitleParserFactory(com.google.common.base.Supplier<java.lang.RuntimeException>)( https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Supplier.html<https://developer.android.com/reference/java/lang/RuntimeException.html> exceptionSupplier )` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` | `https://developer.android.com/reference/androidx/media3/test/utils/ThrowingSubtitleParserFactory#create(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Creates a `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` for the given `https://developer.android.com/reference/androidx/media3/common/Format`. |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/Format.CueReplacementBehavior https://developer.android.com/reference/androidx/media3/test/utils/ThrowingSubtitleParserFactory#getCueReplacementBehavior(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Returns the `https://developer.android.com/reference/androidx/media3/common/Format.CueReplacementBehavior` of the `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` implementation that handles `format`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/ThrowingSubtitleParserFactory#supportsFormat(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Returns whether the factory is able to instantiate a `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` for the given `https://developer.android.com/reference/androidx/media3/common/Format`. |

### Inherited Constants

From [androidx.media3.extractor.text.SubtitleParser.Factory](https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory) `static final https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory` `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory#UNSUPPORTED()`

A subtitle parser factory that supports no formats.

## Constants

### REPLACEMENT_BEHAVIOR

```
@Format.CueReplacementBehavior
public static final int REPLACEMENT_BEHAVIOR = 2
```

## Public constructors

### ThrowingSubtitleParserFactory

```
public ThrowingSubtitleParserFactory(
    Supplier<RuntimeException> exceptionSupplier
)
```

## Public methods

### create

```
public SubtitleParser create(Format format)
```

Creates a `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` for the given `https://developer.android.com/reference/androidx/media3/common/Format`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` | The `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` instance. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `format` is `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory#supportsFormat(androidx.media3.common.Format)` by this factory. |

### getCueReplacementBehavior

```
@Format.CueReplacementBehavior
public int getCueReplacementBehavior(Format format)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/Format.CueReplacementBehavior` of the `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` implementation that handles `format`.

| Returns |
|---|---|
| `int` | The replacement behavior. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `format` is `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory#supportsFormat(androidx.media3.common.Format)` by this factory. |

### supportsFormat

```
public boolean supportsFormat(Format format)
```

Returns whether the factory is able to instantiate a `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser` for the given `https://developer.android.com/reference/androidx/media3/common/Format`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format`. |

| Returns |
|---|---|
| `boolean` | Whether the factory can instantiate a suitable `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser`. |