Skip to content

feat: add playlist_update method to Video control for on-the-fly playlist replacement#6390

Open
bl1nch wants to merge 1 commit intoflet-dev:mainfrom
bl1nch:video
Open

feat: add playlist_update method to Video control for on-the-fly playlist replacement#6390
bl1nch wants to merge 1 commit intoflet-dev:mainfrom
bl1nch:video

Conversation

@bl1nch
Copy link
Copy Markdown
Contributor

@bl1nch bl1nch commented Apr 8, 2026

Description

This PR introduces the playlist_update method to the Video control, allowing the entire playlist to be replaced on the fly. This update can be performed seamlessly even while another video is playing, without the need to manually stop the playback.

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_update_btn_click():
        await video.current.playlist_update(
            [ftv.VideoMedia("https://user-images.githubusercontent.com/28951144/229373718-86ce5e1d-d195-45d5-baa6-ef94041d0b90.mp4")],
            autoplay=True,
        )

    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
        ),
        ft.Button(content="Update playlist", on_click=on_update_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

New Features:

  • Introduce a playlist_update method on the Video control to replace the current playlist at runtime with an optional autoplay flag.

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

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.

1 participant