# 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)

*** ** * ** ***


```
@UnstableApi
public final class DecodeOneFrameUtil
```

<br />

*** ** * ** ***

Utilities for decoding a video frame for tests.

## Summary

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

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil#decodeOneAssetFileFrame(java.lang.String,androidx.media3.test.utils.DecodeOneFrameUtil.Listener,android.view.Surface)( https://developer.android.com/reference/java/lang/String.html assetFilePath, https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil.Listener listener, https://developer.android.com/reference/android/view/Surface.html surface )` Reads and decodes one frame synchronously from the `assetFilePath` and renders it to the `surface`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil#decodeOneMediaItemFrame(androidx.media3.common.MediaItem,androidx.media3.test.utils.DecodeOneFrameUtil.Listener,android.view.Surface)( https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil.Listener listener, https://developer.android.com/reference/android/view/Surface.html surface )` Reads and decodes one frame synchronously from the `mediaItem` and renders it to the `surface`. |

## Public methods

### decodeOneAssetFileFrame

```
public static void decodeOneAssetFileFrame(
    String assetFilePath,
    DecodeOneFrameUtil.Listener listener,
    Surface surface
)
```

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 |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html assetFilePath` | The path to the file in the asset directory. |
| `https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil.Listener listener` | A `https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil.Listener` implementation. |
| `https://developer.android.com/reference/android/view/Surface.html surface` | The `https://developer.android.com/reference/android/view/Surface.html` to render the decoded frame to. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/Exception.html` |   |

### decodeOneMediaItemFrame

```
public static void decodeOneMediaItemFrame(
    MediaItem mediaItem,
    DecodeOneFrameUtil.Listener listener,
    Surface surface
)
```

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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The `https://developer.android.com/reference/androidx/media3/common/MediaItem` from which to decode a frame. |
| `https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil.Listener listener` | A `https://developer.android.com/reference/androidx/media3/test/utils/DecodeOneFrameUtil.Listener` implementation. |
| `https://developer.android.com/reference/android/view/Surface.html surface` | The `https://developer.android.com/reference/android/view/Surface.html` to render the decoded frame to. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/Exception.html` |   |