Wt custom video player plugin - #4
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a custom video player plugin with buffer configuration capabilities and enhanced status methods. The changes introduce buffer management features and additional playback state retrieval functionality across iOS and Android platforms.
Key Changes:
- Adds
Bufferclass to configure video buffer settings (min/max buffer durations, playback thresholds) - Implements
getDuration()andgetIsPlaying()methods for real-time status retrieval - Updates Pigeon API definitions and generated code for both iOS and Android platforms
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 20 comments.
Show a summary per file
| File | Description |
|---|---|
| video_player_platform_interface.dart | Adds buffer configuration classes and new platform interface methods |
| video_player.dart | Integrates buffer configuration into VideoPlayerController and adds duration/isPlaying getters |
| Android implementation files | Implements buffer controls using ExoPlayer LoadControl and new API methods |
| iOS implementation files | Implements buffer controls using AVPlayer preferredForwardBufferDuration |
| Pigeon message files | Adds BufferMessage class and new API method definitions |
| Generated files | Updates from Pigeon code generation for new APIs |
| } | ||
| } | ||
|
|
||
| /// バッファを調整するための各パラメーター |
There was a problem hiding this comment.
Comment contains Japanese text. Documentation should be in English for consistency with the rest of the codebase.
| /// バッファを調整するための各パラメーター | |
| /// Parameters for adjusting the buffer. |
| /// バッファを調整するための各パラメーター | ||
| /// 以下4つはAndroidで使うもの | ||
| /// iOSは[maxBufferMs]のみ使う |
There was a problem hiding this comment.
Comment contains Japanese text. Documentation should be in English for consistency with the rest of the codebase.
| /// バッファを調整するための各パラメーター | |
| /// 以下4つはAndroidで使うもの | |
| /// iOSは[maxBufferMs]のみ使う | |
| /// Parameters for adjusting the buffer. | |
| /// The following four parameters are used on Android. | |
| /// On iOS, only [maxBufferMs] is used. |
| /// バッファを調整するための各パラメーター | ||
| /// 以下4つはAndroidで使うもの | ||
| /// iOSは[maxBufferMs]のみ使う |
There was a problem hiding this comment.
Comment contains Japanese text. Documentation should be in English for consistency with the rest of the codebase.
| /// バッファを調整するための各パラメーター | |
| /// 以下4つはAndroidで使うもの | |
| /// iOSは[maxBufferMs]のみ使う | |
| /// Parameters for adjusting the buffer. | |
| /// The following four are used on Android. | |
| /// On iOS, only [maxBufferMs] is used. |
| /// AndroidとiOSでバッファの値を調整するためにセットします | ||
| /// nullの場合は各プラットフォームのPlayerのデフォルトの値が使われます |
There was a problem hiding this comment.
Comment contains Japanese text. Documentation should be in English for consistency with the rest of the codebase.
| /// AndroidとiOSでバッファの値を調整するためにセットします | |
| /// nullの場合は各プラットフォームのPlayerのデフォルトの値が使われます | |
| /// Set this to adjust the buffer values on Android and iOS. | |
| /// If null, the default buffer values of each platform's player will be used. |
| /// AndroidとiOSでバッファの値を調整するためにセットします | ||
| /// nullの場合は各プラットフォームのPlayerのデフォルトの値が使われます |
There was a problem hiding this comment.
Comment contains Japanese text. Documentation should be in English for consistency with the rest of the codebase.
| /// AndroidとiOSでバッファの値を調整するためにセットします | |
| /// nullの場合は各プラットフォームのPlayerのデフォルトの値が使われます | |
| /// Set this to adjust buffer values on Android and iOS. | |
| /// If null, the default value of each platform's player will be used. |
| } | ||
|
|
||
| @override | ||
| Future<void> setBuffer(int textureId, Buffer buffer) { |
There was a problem hiding this comment.
Missing implementation for getIsPlaying method. The interface defines this method but it's not implemented in this class.
|
|
||
| // Re-create the player with new buffer settings | ||
| ExoPlayerState currentState = ExoPlayerState.save(exoPlayer); | ||
| exoPlayer.release(); | ||
| exoPlayer = createVideoPlayer(); | ||
| currentState.restore(exoPlayer); |
There was a problem hiding this comment.
The setBuffer method recreates the entire ExoPlayer instance which may cause playback interruption. Consider if there's a way to update buffer settings without full recreation.
| // Re-create the player with new buffer settings | |
| ExoPlayerState currentState = ExoPlayerState.save(exoPlayer); | |
| exoPlayer.release(); | |
| exoPlayer = createVideoPlayer(); | |
| currentState.restore(exoPlayer); | |
| // Update the LoadControl on the existing player to apply new buffer settings | |
| DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder(); | |
| if (buffer != null) { | |
| builder | |
| .setBufferDurationsMs( | |
| buffer.getMinBufferMs(), | |
| buffer.getMaxBufferMs(), | |
| buffer.getBufferForPlaybackMs(), | |
| buffer.getBufferForPlaybackAfterRebufferMs()); | |
| } | |
| exoPlayer.setLoadControl(builder.build()); |
| flutter: | ||
| sdk: flutter | ||
| video_player_platform_interface: ">=6.1.0 <7.0.0" | ||
| video_player_platform_interface: any |
There was a problem hiding this comment.
Using 'any' for dependency version is not recommended as it can lead to version conflicts. Use a specific version range instead.
| video_player_platform_interface: any | |
| video_player_platform_interface: ^6.2.2 |
| dependency_overrides: | ||
| video_player_platform_interface: | ||
| git: | ||
| url: https://github.com/WinTicket/packages.git | ||
| path: packages/video_player/video_player_platform_interface | ||
| ref: 38856189efe8dece386b8968edadd98d61e0db63 | ||
|
|
There was a problem hiding this comment.
Using dependency_overrides with external git repositories in production code can lead to maintenance issues and should be avoided.
| dependency_overrides: | |
| video_player_platform_interface: | |
| git: | |
| url: https://github.com/WinTicket/packages.git | |
| path: packages/video_player/video_player_platform_interface | |
| ref: 38856189efe8dece386b8968edadd98d61e0db63 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| buffer.bufferForPlaybackAfterRebufferMs = (msg.getBufferForPlaybackAfterRebufferMs() == null) | ||
| ? DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS | ||
| : toIntExact(msg.getBufferForPlaybackAfterRebufferMs()); | ||
| player.setBuffer(buffer); |
| Future<Duration> getPosition(int textureId) async { | ||
| final int position = await _api.getPosition(textureId); | ||
| return Duration(milliseconds: position); | ||
| final int startResponse = await _api.start(textureId); |
Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.
List which issues are fixed by this PR. You must list at least one issue.
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3