[video_player] Add opt-in Android renderer options to mitigate MediaCodec initialization failures#11338
[video_player] Add opt-in Android renderer options to mitigate MediaCodec initialization failures#11338maeddin wants to merge 2 commits intoflutter:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces VideoPlayerAndroidOptions to allow per-instance configuration of Android-specific renderer settings. The new options, enableDecoderFallback and disableMediaCodecAsyncQueueing, are passed from the Dart VideoPlayerController down to the native Android implementation. On Android, these options are used to configure a DefaultRenderersFactory for the ExoPlayer instance, which can help mitigate MediaCodec initialization failures. The changes span across the video_player, video_player_platform_interface, and video_player_android packages, including updates to data models, API methods, and the addition of corresponding tests to ensure the options are correctly forwarded and applied.
…d_options # Conflicts: # packages/video_player/video_player/CHANGELOG.md # packages/video_player/video_player/pubspec.yaml # packages/video_player/video_player/test/video_player_test.dart
Description
This adds Android-only player creation options to
video_playerso apps can configure Media3 renderer behavior per player instance.This is intended to mitigate MediaCodec and decoder initialization failures on some Android devices, especially in scenarios where multiple video players are created, as reported in flutter/flutter#25558.
The new API introduces
VideoPlayerAndroidOptions, which can be passed viaVideoPlayerOptions.androidOptions. These values are forwarded throughVideoCreationOptionsintovideo_player_androidduring player creation.On Android, the plugin now creates a
DefaultRenderersFactoryfor each player instance and applies:setEnableDecoderFallback(enableDecoderFallback)forceDisableMediaCodecAsynchronousQueueing()whendisableMediaCodecAsyncQueueingistrueThis gives affected apps an opt-in way to reduce decoder initialization failures without changing default behavior for existing users.
If
androidOptionsis not provided, behavior remains unchanged.Non-Android platforms ignore these options.
API changes
Example usage:
Fixes flutter/flutter#25558.
Pre-Review Checklist
[shared_preferences]///).