# VideoRendererEventListener

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

*** ** * ** ***


```
@UnstableApi
public interface VideoRendererEventListener
```

<br />

*** ** * ** ***

Listener of video `https://developer.android.com/reference/androidx/media3/exoplayer/Renderer` events. All methods have no-op default implementations to allow selective overrides.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener.EventDispatcher` Dispatches events to a `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener`. |

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onDroppedFrames(int,long)(int count, long elapsedMs)` Called to report the number of frames dropped by the renderer. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onRenderedFirstFrame(java.lang.Object,long)(https://developer.android.com/reference/java/lang/Object.html output, long renderTimeMs)` Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoCodecError(java.lang.Exception)(https://developer.android.com/reference/java/lang/Exception.html videoCodecError)` Called when a video decoder encounters an error. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoCodecParametersChanged(androidx.media3.exoplayer.CodecParameters)(https://developer.android.com/reference/androidx/media3/exoplayer/CodecParameters codecParameters)` Called when the video codec parameters change. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoDecoderInitialized(java.lang.String,long,long)( https://developer.android.com/reference/java/lang/String.html decoderName, long initializedTimestampMs, long initializationDurationMs )` Called when a decoder is created. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoDecoderReleased(java.lang.String)(https://developer.android.com/reference/java/lang/String.html decoderName)` Called when a decoder is released. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoDisabled(androidx.media3.exoplayer.DecoderCounters)(https://developer.android.com/reference/androidx/media3/exoplayer/DecoderCounters counters)` Called when the renderer is disabled. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoEnabled(androidx.media3.exoplayer.DecoderCounters)(https://developer.android.com/reference/androidx/media3/exoplayer/DecoderCounters counters)` Called when the renderer is enabled. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoFrameProcessingOffset(long,int)( long totalProcessingOffsetUs, int frameCount )` Called to report the video processing offset of video frames processed by the video renderer. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoInputFormatChanged(androidx.media3.common.Format,androidx.media3.exoplayer.DecoderReuseEvaluation)( https://developer.android.com/reference/androidx/media3/common/Format format, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/DecoderReuseEvaluation decoderReuseEvaluation )` Called when the format of the media being consumed by the renderer changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoRendererEventListener#onVideoSizeChanged(androidx.media3.common.VideoSize)(https://developer.android.com/reference/androidx/media3/common/VideoSize videoSize)` Called before a frame is rendered for the first time since setting the surface, and each time there's a change in the size, rotation or pixel aspect ratio of the video being rendered. |

## Public methods

### onDroppedFrames

```
default void onDroppedFrames(int count, long elapsedMs)
```

Called to report the number of frames dropped by the renderer. Dropped frames are reported whenever the renderer is stopped having dropped frames, and optionally, whenever the count reaches a specified threshold whilst the renderer is started.

| Parameters |
|---|---|
| `int count` | The number of dropped frames. |
| `long elapsedMs` | The duration in milliseconds over which the frames were dropped. This duration is timed from when the renderer was started or from when dropped frames were last reported (whichever was more recent), and not from when the first of the reported drops occurred. |

### onRenderedFirstFrame

```
default void onRenderedFirstFrame(Object output, long renderTimeMs)
```

Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html output` | The output of the video renderer. Normally a `https://developer.android.com/reference/android/view/Surface.html`, however some video renderers may have other output types (e.g., a `https://developer.android.com/reference/androidx/media3/exoplayer/video/VideoDecoderOutputBufferRenderer`). |
| `long renderTimeMs` | The `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` when the frame was rendered. |

### onVideoCodecError

```
default void onVideoCodecError(Exception videoCodecError)
```

Called when a video decoder encounters an error.

This method being called does not indicate that playback has failed, or that it will fail. The player may be able to recover from the error. Hence applications should *not* implement this method to display a user visible error or initiate an application level retry. `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayerError(androidx.media3.common.PlaybackException)` is the appropriate place to implement such behavior. This method is called to provide the application with an opportunity to log the error if it wishes to do so.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/Exception.html videoCodecError` | The error. Typically a `https://developer.android.com/reference/android/media/MediaCodec.CodecException.html` if the renderer uses `https://developer.android.com/reference/android/media/MediaCodec.html`, or a `https://developer.android.com/reference/androidx/media3/decoder/DecoderException` if the renderer uses a software decoder. |

### onVideoCodecParametersChanged

```
default void onVideoCodecParametersChanged(CodecParameters codecParameters)
```

Called when the video codec parameters change.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/CodecParameters codecParameters` | The new codec parameters. |

### onVideoDecoderInitialized

```
default void onVideoDecoderInitialized(
    String decoderName,
    long initializedTimestampMs,
    long initializationDurationMs
)
```

Called when a decoder is created.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html decoderName` | The decoder that was created. |
| `long initializedTimestampMs` | `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` when initialization finished. |
| `long initializationDurationMs` | The time taken to initialize the decoder in milliseconds. |

### onVideoDecoderReleased

```
default void onVideoDecoderReleased(String decoderName)
```

Called when a decoder is released.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html decoderName` | The decoder that was released. |

### onVideoDisabled

```
default void onVideoDisabled(DecoderCounters counters)
```

Called when the renderer is disabled.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/DecoderCounters counters` | `https://developer.android.com/reference/androidx/media3/exoplayer/DecoderCounters` that were updated by the renderer. |

### onVideoEnabled

```
default void onVideoEnabled(DecoderCounters counters)
```

Called when the renderer is enabled.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/DecoderCounters counters` | `https://developer.android.com/reference/androidx/media3/exoplayer/DecoderCounters` that will be updated by the renderer for as long as it remains enabled. |

### onVideoFrameProcessingOffset

```
default void onVideoFrameProcessingOffset(
    long totalProcessingOffsetUs,
    int frameCount
)
```

Called to report the video processing offset of video frames processed by the video renderer.

Video processing offset represents how early a video frame is processed compared to the player's current position. For each video frame, the offset is calculated as *Pvf - Ppl* where *Pvf* is the presentation timestamp of the video frame and *Ppl* is the current position of the player. Positive values indicate the frame was processed early enough whereas negative values indicate that the player's position had progressed beyond the frame's timestamp when the frame was processed (and the frame was probably dropped).

The renderer reports the sum of video processing offset samples (one sample per processed video frame: dropped, skipped or rendered) and the total number of samples.

| Parameters |
|---|---|
| `long totalProcessingOffsetUs` | The sum of all video frame processing offset samples for the video frames processed by the renderer in microseconds. |
| `int frameCount` | The number of samples included in the `totalProcessingOffsetUs`. |

### onVideoInputFormatChanged

```
default void onVideoInputFormatChanged(
    Format format,
    @Nullable DecoderReuseEvaluation decoderReuseEvaluation
)
```

Called when the format of the media being consumed by the renderer changes.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The new format. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/DecoderReuseEvaluation decoderReuseEvaluation` | The result of the evaluation to determine whether an existing decoder instance can be reused for the new format, or `null` if the renderer did not have a decoder. |

### onVideoSizeChanged

```
default void onVideoSizeChanged(VideoSize videoSize)
```

Called before a frame is rendered for the first time since setting the surface, and each time there's a change in the size, rotation or pixel aspect ratio of the video being rendered.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/VideoSize videoSize` | The new size of the video. |