# ColorParser

# ColorParser

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/common/util/ColorParser "View this page in Java")

<br />

```
@UnstableApi
class ColorParser
```

<br />

*** ** * ** ***

Parser for color expressions found in styling formats, e.g. TTML and CSS.

See also:

- [WebVTT CSS Styling](https://w3c.github.io/webvtt/#styling)
- [Timed Text Markup Language 2 (TTML2) - 10.3.5](https://www.w3.org/TR/ttml2/)

## Summary

|                                                                                 ### Public functions                                                                                 |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [parseCssColor](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ColorParser#parseCssColor(java.lang.String))`(colorExpression: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Parses a CSS color expression.    |
| `java-static @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [parseTtmlColor](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ColorParser#parseTtmlColor(java.lang.String))`(colorExpression: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Parses a TTML color expression. |

## Public functions

### parseCssColor

```
java-static fun parseCssColor(colorExpression: String!): @ColorInt Int
```

Parses a CSS color expression.  

|                                               Parameters                                                |
|---------------------------------------------------------------------------------------------------------|-----------------------|
| `colorExpression: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The color expression. |

|                                                                                 Returns                                                                                  |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|
| `@`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The parsed ARGB color. |

### parseTtmlColor

```
java-static fun parseTtmlColor(colorExpression: String!): @ColorInt Int
```

Parses a TTML color expression.  

|                                               Parameters                                                |
|---------------------------------------------------------------------------------------------------------|-----------------------|
| `colorExpression: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The color expression. |

|                                                                                 Returns                                                                                  |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|
| `@`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The parsed ARGB color. |