Skip to content

Add FVPController class with working appendBuffer support#342

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/support-appendbuffer-fvpcontrollerextensions
Draft

Add FVPController class with working appendBuffer support#342
Copilot wants to merge 3 commits intomasterfrom
copilot/support-appendbuffer-fvpcontrollerextensions

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 27, 2026

appendBuffer in FVPControllerExtensions is fundamentally broken for its primary use case: _getId() reads textureId/playerId, which are only valid after initialize() completes — but appendBuffer must be called during initialization while prepare() is blocked waiting for data from a mdk: source.

Solution: FVPController class

Replaces the extension-based approach with a new FVPController extends VideoPlayerController that pre-creates the underlying MdkVideoPlayer in the constructor, keyed by its stable nativeHandle throughout the full lifecycle.

Platform changes (video_player_mdk.dart)

  • _playersByHandle <int, MdkVideoPlayer> — tracks all FVP-managed players by nativeHandle from construction to disposal
  • _promotedHandles <int> — O(1) set tracking which handles have been added to _players via create()
  • _nextPlayerHandle — hint set by FVPController.initialize() so create() reuses the pre-created player instead of allocating a new one
  • New methods: createPendingPlayer(), setNextPlayerHandle(), clearNextPlayerHandle(), discardPendingPlayer(), appendBufferByHandle()
  • dispose() now cleans up _playersByHandle and _promotedHandles
  • Removed the now-unused appendBuffer(playerId, ...) overload

Controller changes (controller.dart)

  • Removes appendBuffer from FVPControllerExtensions
  • Adds FVPController with .network(), .asset(), .file() constructors, appendBuffer(), and overridden initialize()/dispose()

Usage

final ctrl = FVPController.network('mdk:');
final initFuture = ctrl.initialize(); // don't await yet
ctrl.appendBuffer(chunk1);
ctrl.appendBuffer(chunk2, flags: -1); // -1 = end-of-stream
await initFuture; // completes once prepare() has enough data

appendBuffer works at all lifecycle stages — before, during, and after initialize().


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] Add support for appendBuffer in FVPControllerExtensions Add appendBuffer() to FVPControllerExtensions Mar 27, 2026
Copilot AI requested a review from wang-bin March 27, 2026 15:35
Copilot AI changed the title Add appendBuffer() to FVPControllerExtensions Add FVPController class with working appendBuffer support Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants