Skip to content

[video_player] Add Android decoder fallback option#11954

Open
Jasonli-cc wants to merge 1 commit into
flutter:mainfrom
Jasonli-cc:codex/android-decoder-fallback
Open

[video_player] Add Android decoder fallback option#11954
Jasonli-cc wants to merge 1 commit into
flutter:mainfrom
Jasonli-cc:codex/android-decoder-fallback

Conversation

@Jasonli-cc

Copy link
Copy Markdown

Summary

  • add VideoPlayerAndroidOptions.enableDecoderFallback and forward it through VideoCreationOptions
  • configure Android texture and platform-view ExoPlayer paths with DefaultRenderersFactory.setEnableDecoderFallback
  • update Pigeon messages, package versions/changelogs, and focused Dart/Android tests

Tests

  • flutter test in packages/video_player/video_player_platform_interface
  • dart run script/tool/bin/flutter_plugin_tools.dart format --packages video_player,video_player_platform_interface,video_player_android (Java/Kotlin formatted; exits because clang-format is unavailable locally)
  • dart run script/tool/bin/flutter_plugin_tools.dart analyze --packages video_player,video_player_platform_interface,video_player_android (blocked for video_player by unpublished local video_player_platform_interface ^6.8.0; blocked for video_player_android by local Dart 3.10.7 vs package ^3.12.0; platform_interface analyzed cleanly)
  • dart run script/tool/bin/flutter_plugin_tools.dart dart-test --packages video_player,video_player_platform_interface,video_player_android (same two local dependency/SDK blockers; platform_interface and other runnable federated tests passed)

@google-cla

google-cla Bot commented Jun 22, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for enabling ExoPlayer's decoder fallback on Android by introducing VideoPlayerAndroidOptions.enableDecoderFallback across the video_player, video_player_platform_interface, and video_player_android packages. The feedback suggests extracting the identical createExoPlayer methods in PlatformViewVideoPlayer and TextureVideoPlayer into a shared utility class to reduce code duplication.

Comment on lines +66 to 79
public static ExoPlayer createExoPlayer(
@NonNull Context context,
@NonNull VideoAsset asset,
@NonNull VideoPlayerOptions options,
@NonNull DefaultRenderersFactory renderersFactory) {
androidx.media3.exoplayer.trackselection.DefaultTrackSelector trackSelector =
new androidx.media3.exoplayer.trackselection.DefaultTrackSelector(context);
renderersFactory.setEnableDecoderFallback(options.enableDecoderFallback);
ExoPlayer.Builder builder =
new ExoPlayer.Builder(context, renderersFactory)
.setTrackSelector(trackSelector)
.setMediaSourceFactory(asset.getMediaSourceFactory(context));
return builder.build();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The createExoPlayer method is identical to the one implemented in TextureVideoPlayer.java. To avoid code duplication and improve maintainability, consider extracting this method into a shared utility class (e.g., ExoPlayerUtils) within the io.flutter.plugins.videoplayer package.

Comment on lines +66 to 79
public static ExoPlayer createExoPlayer(
@NonNull Context context,
@NonNull VideoAsset asset,
@NonNull VideoPlayerOptions options,
@NonNull DefaultRenderersFactory renderersFactory) {
androidx.media3.exoplayer.trackselection.DefaultTrackSelector trackSelector =
new androidx.media3.exoplayer.trackselection.DefaultTrackSelector(context);
renderersFactory.setEnableDecoderFallback(options.enableDecoderFallback);
ExoPlayer.Builder builder =
new ExoPlayer.Builder(context, renderersFactory)
.setTrackSelector(trackSelector)
.setMediaSourceFactory(asset.getMediaSourceFactory(context));
return builder.build();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The createExoPlayer method is identical to the one implemented in PlatformViewVideoPlayer.java. To avoid code duplication and improve maintainability, consider extracting this method into a shared utility class (e.g., ExoPlayerUtils) within the io.flutter.plugins.videoplayer package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant