# DecodeOneFrameUtil

# DecodeOneFrameUtil

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/DecodeOneFrameUtil.java+class:androidx.media3.test.utils.DecodeOneFrameUtil)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil "View this page in Java")

<br />

```
@UnstableApi
class DecodeOneFrameUtil
```

<br />

*** ** * ** ***

Utilities for decoding a video frame for tests.

## Summary

|                                                                                ### Nested types                                                                                |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interface `[DecodeOneFrameUtil.Listener](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil.Listener) Listener for decoding events. |

|                                    ### Public functions                                     |
|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [decodeOneAssetFileFrame](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil#decodeOneAssetFileFrame(java.lang.String,androidx.media3.test.utils.DecodeOneFrameUtil.Listener,android.view.Surface))`(` ` assetFilePath: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!,` ` listener: `[DecodeOneFrameUtil.Listener](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil.Listener)`!,` ` surface: `[Surface](https://developer.android.com/reference/android/view/Surface.html)`!` `)` Reads and decodes one frame synchronously from the`assetFilePath`and renders it to the`surface`.                    |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [decodeOneMediaItemFrame](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil#decodeOneMediaItemFrame(androidx.media3.common.MediaItem,androidx.media3.test.utils.DecodeOneFrameUtil.Listener,android.view.Surface))`(` ` mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!,` ` listener: `[DecodeOneFrameUtil.Listener](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil.Listener)`!,` ` surface: `[Surface](https://developer.android.com/reference/android/view/Surface.html)`!` `)` Reads and decodes one frame synchronously from the`mediaItem`and renders it to the`surface`. |

## Public functions

### decodeOneAssetFileFrame

```
java-static fun decodeOneAssetFileFrame(
    assetFilePath: String!,
    listener: DecodeOneFrameUtil.Listener!,
    surface: Surface!
): Unit
```

Reads and decodes one frame synchronously from the`assetFilePath`and renders it to the`surface`.

This method blocks until the frame has been rendered to the`surface`.  

|                                                                     Parameters                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `assetFilePath: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`                                               | The path to the file in the asset directory.                                                                                      |
| `listener: `[DecodeOneFrameUtil.Listener](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil.Listener)`!` | A[Listener](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil.Listener)implementation. |
| `surface: `[Surface](https://developer.android.com/reference/android/view/Surface.html)`!`                                                          | The[Surface](https://developer.android.com/reference/android/view/Surface.html)to render the decoded frame to.                    |

|                                         Throws                                          |
|-----------------------------------------------------------------------------------------|---|
| [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception.html) |   |

### decodeOneMediaItemFrame

```
java-static fun decodeOneMediaItemFrame(
    mediaItem: MediaItem!,
    listener: DecodeOneFrameUtil.Listener!,
    surface: Surface!
): Unit
```

Reads and decodes one frame synchronously from the`mediaItem`and renders it to the`surface`.

This method blocks until the frame has been rendered to the`surface`.  

|                                                                     Parameters                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `mediaItem: `[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)`!`                                        | The[MediaItem](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem)from which to decode a frame.      |
| `listener: `[DecodeOneFrameUtil.Listener](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil.Listener)`!` | A[Listener](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/DecodeOneFrameUtil.Listener)implementation. |
| `surface: `[Surface](https://developer.android.com/reference/android/view/Surface.html)`!`                                                          | The[Surface](https://developer.android.com/reference/android/view/Surface.html)to render the decoded frame to.                    |

|                                         Throws                                          |
|-----------------------------------------------------------------------------------------|---|
| [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception.html) |   |