Skip to content

feat: add content property to Video control#6392

Open
bl1nch wants to merge 6 commits intoflet-dev:release/v0.85.0from
bl1nch:video-custom-controls
Open

feat: add content property to Video control#6392
bl1nch wants to merge 6 commits intoflet-dev:release/v0.85.0from
bl1nch:video-custom-controls

Conversation

@bl1nch
Copy link
Copy Markdown
Contributor

@bl1nch bl1nch commented Apr 8, 2026

Description

This PR adds a content property to the Video control. It allows developers to replace the standard media_kit playback controls with a custom Flet control (e.g., a Container, Stack, or Row with custom buttons/text/other controls).

Test Code

# Test code for the review of this PR
import flet as ft
import flet_video as ftv


async def main(page: ft.Page):
    video = ft.Ref[ftv.Video]()

    async def on_inner_btn_click():
        await video.current.stop()

    async def on_play_btn_click():
        await video.current.play()

    async def on_stop_btn_click():
        await video.current.stop()

    page.add(
        ftv.Video(
            playlist=[ftv.VideoMedia("https://user-images.githubusercontent.com/28951144/229373720-14d69157-1a56-4a78-a2f4-d7a134d7c3e9.mp4")],
            height=500,
            width=700,
            ref=video,
            content=ft.Stack(
                controls=[
                    ft.Button(content="Stop <EXAMPLE>", on_click=on_inner_btn_click),
                ]
            )
        ),
        ft.Button(content="Play", on_click=on_play_btn_click),
        ft.Button(content="Stop", on_click=on_stop_btn_click),
    )


ft.run(main=main)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots

Additional details

Summary by Sourcery

Add support for custom content in the Video control and provide an example usage.

New Features:

  • Add a content property to the Video control to allow injecting custom Flet controls in place of the default player controls.
  • Expose a host_expanded initialization behavior for Video to ensure the host container expands when using custom content.
  • Add a new example app demonstrating custom Video content configuration and controls.

Documentation:

  • Document the new Video.content property in the Python Video control docstring.
  • Mention the new Video content capability in the project changelog.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@Dejv311
Copy link
Copy Markdown
Contributor

Dejv311 commented Apr 10, 2026

That is a really cool feature! Thanks for the PR :)

@FeodorFitsner
Copy link
Copy Markdown
Contributor

Change PR base branch to release/v0.85.0 and add:

  1. CHANGELOG record.
  2. example to sdk/python/examples/controls/video.

@bl1nch bl1nch changed the base branch from main to release/v0.85.0 April 13, 2026 05:59
@bl1nch bl1nch force-pushed the video-custom-controls branch from 18ea9dd to 1f7a0e1 Compare April 13, 2026 06:35
@bl1nch bl1nch marked this pull request as draft April 13, 2026 10:54
@bl1nch bl1nch marked this pull request as ready for review April 13, 2026 17:06
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

def init(self):
super().init()
self._internals["host_expanded"] = True

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.

Why do we need this?

if (content != null) {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
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.

I'm not sure hard-coded column wrapper is a good idea. I'd leave content a generic control and let user decide what to put there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The problem is that media_kit forces any widget passed to controls to expand and stretches it to the full area of the player. I thought it would be better to wrap content in a Column before passing it to controls. This way, we create a feeling that the Video control itself is like a separate View.
self._internals["host_expanded"] = True is used so that the widget passed to content supports expand=True, but it is not mandatory for it.
What do you think about this?

@FeodorFitsner
Copy link
Copy Markdown
Contributor

Could you fix a merge conflict please.

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.

3 participants