From b0aabfd9eb79354c12a1eb979c8d12d6678fcff4 Mon Sep 17 00:00:00 2001 From: Dejv311 Date: Tue, 20 Jan 2026 13:38:56 +0100 Subject: [PATCH 1/4] flet-video: add mpv_properties to VideoConfiguration --- .../flet-video/src/flet_video/types.py | 16 +++++++++- .../src/flutter/flet_video/lib/src/video.dart | 32 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/sdk/python/packages/flet-video/src/flet_video/types.py b/sdk/python/packages/flet-video/src/flet_video/types.py index 77db740de..078aaebef 100644 --- a/sdk/python/packages/flet-video/src/flet_video/types.py +++ b/sdk/python/packages/flet-video/src/flet_video/types.py @@ -91,6 +91,20 @@ class VideoConfiguration: """ + mpv_properties: Optional[dict[str, str | int | float | bool]] = None + """ + Extra mpv/libmpv properties to set on native backend only (Windows/macOS/Linux/iOS/Android). + This dictionary is applied to the underlying media_kit `NativePlayer` before opening media. + Keys correspond to mpv option/property names without the leading '--'. + + Example: + `{ + 'profile': 'low-latency', + 'untimed': 'yes', + }` + """ + + @dataclass class VideoSubtitleTrack: """Represents a subtitle track for a video.""" @@ -214,4 +228,4 @@ class VideoSubtitleConfiguration: visible: bool = True """ Whether the subtitles should be visible or not. - """ + """ \ No newline at end of file diff --git a/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart b/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart index bde5ab167..0e25984d9 100644 --- a/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart +++ b/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart @@ -25,6 +25,26 @@ class _VideoControlState extends State with FletStoreMixin { late VideoController _controller; bool _initialized = false; + Future _applyMpvProperties(Control control) async { + final cfg = control.get("configuration"); + if (cfg is! Map) return; + + final mpvPropsRaw = cfg["mpv_properties"]; + if (mpvPropsRaw is! Map) return; + + if (_player.platform is! NativePlayer) return; + final native = _player.platform as NativePlayer; + + for (final entry in mpvPropsRaw.entries) { + final key = entry.key.toString(); + final val = entry.value; + if (val == null) continue; + final valueStr = val is bool ? (val ? "yes" : "no") : val.toString(); + await native.setProperty(key, valueStr); + } + } + + void _setup(Control control) { final playerConfig = PlayerConfiguration( title: control.getString("title", "flet-video")!, @@ -64,8 +84,14 @@ class _VideoControlState extends State with FletStoreMixin { }); } - _player.open(Playlist(parseVideoMedias(control.get("playlist"), [])!), - play: control.getBool("autoplay", false)!); + final playlist = + Playlist(parseVideoMedias(control.get("playlist"), [])!); + final autoplay = control.getBool("autoplay", false)!; + + () async { + await _applyMpvProperties(control); + await _player.open(playlist, play: autoplay); + }(); } void _teardown(Control control) { @@ -294,4 +320,4 @@ class _VideoControlState extends State with FletStoreMixin { return ConstrainedControl(control: widget.control, child: video); } -} +} \ No newline at end of file From 6d2c75bf8c7831e3278aa4890d2f3aa068fbb67f Mon Sep 17 00:00:00 2001 From: Dejv311 Date: Wed, 21 Jan 2026 11:17:35 +0100 Subject: [PATCH 2/4] bugfix: fix compilation error for web --- .../flet-video/src/flutter/flet_video/lib/src/video.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart b/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart index 0e25984d9..535b76bd4 100644 --- a/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart +++ b/sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart @@ -32,8 +32,9 @@ class _VideoControlState extends State with FletStoreMixin { final mpvPropsRaw = cfg["mpv_properties"]; if (mpvPropsRaw is! Map) return; - if (_player.platform is! NativePlayer) return; - final native = _player.platform as NativePlayer; + final platform = _player.platform; + if (platform is! NativePlayer) return; + final native = platform as dynamic; for (final entry in mpvPropsRaw.entries) { final key = entry.key.toString(); From 1e2141ae99af4fd0579858bedbb8e045371bd855 Mon Sep 17 00:00:00 2001 From: Dejv311 Date: Wed, 21 Jan 2026 11:26:40 +0100 Subject: [PATCH 3/4] docs: Improve mpv_properties documentation --- sdk/python/packages/flet-video/src/flet_video/types.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/python/packages/flet-video/src/flet_video/types.py b/sdk/python/packages/flet-video/src/flet_video/types.py index 078aaebef..e2649928b 100644 --- a/sdk/python/packages/flet-video/src/flet_video/types.py +++ b/sdk/python/packages/flet-video/src/flet_video/types.py @@ -95,12 +95,14 @@ class VideoConfiguration: """ Extra mpv/libmpv properties to set on native backend only (Windows/macOS/Linux/iOS/Android). This dictionary is applied to the underlying media_kit `NativePlayer` before opening media. - Keys correspond to mpv option/property names without the leading '--'. + Keys correspond to mpv option/property names without the leading '--' (`--hdr-compute-peak` becomes `hdr-compute-peak`). + All values are converted to String. Boolean values are converted to `yes`/`no`. + See the full list of parameters: https://mpv.io/manual/stable/#options Example: `{ 'profile': 'low-latency', - 'untimed': 'yes', + 'untimed': True, }` """ From 0b375ee5a9d9f6dca7d2063f9adab47ac6ba79ef Mon Sep 17 00:00:00 2001 From: ndonkoHenri Date: Fri, 23 Jan 2026 01:43:58 +0100 Subject: [PATCH 4/4] Update mpv_properties type hint and improve documentation for clarity --- .../flet-video/src/flet_video/types.py | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/sdk/python/packages/flet-video/src/flet_video/types.py b/sdk/python/packages/flet-video/src/flet_video/types.py index e2649928b..f25308ec0 100644 --- a/sdk/python/packages/flet-video/src/flet_video/types.py +++ b/sdk/python/packages/flet-video/src/flet_video/types.py @@ -4,7 +4,7 @@ from dataclasses import dataclass, field from enum import Enum -from typing import Optional +from typing import Optional, Union import flet as ft @@ -90,20 +90,27 @@ class VideoConfiguration: Specifying this option will cause [`width`][(c).] & [`height`][(c).] to be ignored. """ - - mpv_properties: Optional[dict[str, str | int | float | bool]] = None + mpv_properties: Optional[dict[str, Union[str, int, float, bool]]] = None """ - Extra mpv/libmpv properties to set on native backend only (Windows/macOS/Linux/iOS/Android). - This dictionary is applied to the underlying media_kit `NativePlayer` before opening media. - Keys correspond to mpv option/property names without the leading '--' (`--hdr-compute-peak` becomes `hdr-compute-peak`). - All values are converted to String. Boolean values are converted to `yes`/`no`. - See the full list of parameters: https://mpv.io/manual/stable/#options + Extra mpv/libmpv properties to set on + native backends (Windows/macOS/Linux/iOS/Android). + + The keys are mpv option/property names without the leading `--`. Values can be + `str`, `int`, `float` or `bool`. All values are converted to strings before being + passed to mpv; boolean values are converted to `"yes"` / `"no"`. + + Full list of mpv options: https://mpv.io/manual/stable/#options Example: - `{ - 'profile': 'low-latency', - 'untimed': True, - }` + ```python + >>> VideoConfiguration( + mpv_properties={ + "profile": "low-latency", # --profile=low-latency + "untimed": True, # --untimed + "volume": 80, # --volume=80 + } + ) + ``` """ @@ -230,4 +237,4 @@ class VideoSubtitleConfiguration: visible: bool = True """ Whether the subtitles should be visible or not. - """ \ No newline at end of file + """