Back to Flet

Video

website/docs/controls/video/index.md

0.85.0.dev23.4 KB
Original Source

import TabItem from '@theme/TabItem'; import Tabs from '@theme/Tabs'; import {ClassAll, CodeExample} from '@site/src/components/crocodocs';

Video

Embed a full-featured video player in your Flet app with playlist support, hardware acceleration controls, and subtitle configuration.

It is powered by the media_kit Flutter package.

Platform Support

PlatformWindowsmacOSLinuxiOSAndroidWeb
Supported

Usage

Add the flet-video package to your project dependencies:

<Tabs groupId="uv--pip"> <TabItem value="uv" label="uv"> ```bash uv add flet-video ``` </TabItem> <TabItem value="pip" label="pip"> ```bash pip install flet-video # (1)! ```
  1. After this, you will have to manually add this package to your requirements.txt or pyproject.toml. </TabItem>
</Tabs> ## Requirements

The below sections show the required configurations for each platform.

Android

You may need to declare and request file-system/storage permissions, depending on your use case:

<Tabs groupId="flet-build--pyproject-toml"> <TabItem value="flet-build" label="flet build"> ```bash flet build apk \ --android-permissions android.permission.READ_MEDIA_AUDIO=true \ --android-permissions android.permission.READ_MEDIA_VIDEO=true \ --android-permissions android.permission.READ_EXTERNAL_STORAGE=true \ --android-permissions android.permission.WRITE_EXTERNAL_STORAGE=true ``` </TabItem> <TabItem value="pyproject-toml" label="pyproject.toml"> ```toml [tool.flet.android.permission] "android.permission.READ_MEDIA_AUDIO" = true "android.permission.READ_MEDIA_VIDEO" = true "android.permission.READ_EXTERNAL_STORAGE" = true "android.permission.WRITE_EXTERNAL_STORAGE" = true ``` </TabItem> </Tabs> Use [`PermissionHandler`](../../services/permissionhandler/index.md) to **request** permissions at runtime.

See also:

Linux

libmpv libraries must be installed and present on the machine running the app.

On Ubuntu/Debian, this can be done with:

bash
sudo apt install libmpv-dev mpv

If you encounter libmpv.so.1 load errors, run:

bash
sudo apt update
sudo apt install libmpv-dev libmpv2
sudo ln -s /usr/lib/x86_64-linux-gnu/libmpv.so /usr/lib/libmpv.so.1

Examples

Basic example

<CodeExample path={frontMatter.examples + '/example_1/main.py'} language="python" />

Description

<ClassAll name={frontMatter.class_name} />