Skip to main content

flet-media-scanner

A Flet extension for Android MediaStore integration — save, list, and delete videos in the device Gallery without requiring broad storage permissions.

Supports MP4, MKV (Matroska), WebM, and other common video containers. MIME type is resolved automatically from the file extension.

Requirements

  • Platform: Android only (no-op on other platforms)
  • Android: API 23+ (minSdk 23)
  • Flet: >= 0.86.0

Supported Formats

Extension MIME Type
.mp4 video/mp4
.mkv video/x-matroska
.webm video/webm
.avi video/x-msvideo
.mov video/quicktime
.3gp video/3gpp
.ts video/mp2t
.flv video/x-flv

Installation

pip install flet-media-scanner

Setup

Register the extension in your pyproject.toml:

[tool.flet.extensions]
flet_media_scanner = "flet_media_scanner.Extension"

Usage

import flet as ft
from flet_media_scanner import MediaScanner, SaveResult

async def main(page: ft.Page):
    scanner = MediaScanner()
    page.services.append(scanner)
    page.update()

    # Save a video to the Gallery (Movies/MyApp folder)
    result: SaveResult = await scanner.save_video(
        "/data/user/0/com.example.app/cache/video.mp4",
        file_name="my_video.mp4",
        album="MyApp",
    )
    if result.success:
        print(f"Saved: {result.content_uri}")
    else:
        print(f"Error: {result.error}")

    # List videos in the album
    videos = await scanner.list_videos(album="MyApp")
    for v in videos:
        print(v["display_name"], v["content_uri"])

    # Delete a video by content URI
    deleted = await scanner.delete_video("content://media/external/video/media/123")
    print("Deleted:", deleted)

ft.run(main)

API

MediaScanner (Service)

Add to page.services before calling any methods.

await save_video(file_path, file_name=None, album="MyApp") → SaveResult

Copies a private app file into Android MediaStore (Movies/<album>). Works on Android 10+ without broad storage permissions.

Parameter Type Description
file_path str Absolute path to the source video file
file_name str | None Display name in Gallery (defaults to basename)
album str Subfolder inside Movies/

await list_videos(album="MyApp") → list[dict]

Returns all videos previously saved to the album. Each dict contains: display_name, content_uri, mime_type, relative_path, size, date_added.

await delete_video(content_uri) → bool

Deletes a MediaStore item by its content:// URI.

await scan_media(file_path) → bool

(Legacy) Triggers a media scan for a file that already exists in public storage. Use save_video() for new downloads instead.


SaveResult (dataclass)

Field Type Description
success bool Whether the operation succeeded
content_uri str MediaStore content:// URI
display_name str File name as shown in Gallery
mime_type str e.g. video/mp4
relative_path str e.g. Movies/MyApp/
size int File size in bytes
error str Error message if success=False

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flet_media_scanner-0.86.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flet_media_scanner-0.86.2-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file flet_media_scanner-0.86.2.tar.gz.

File metadata

  • Download URL: flet_media_scanner-0.86.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for flet_media_scanner-0.86.2.tar.gz
Algorithm Hash digest
SHA256 130880c9884ad9f8161f2c704dccd0ccdc2ca7c91154793d5e140d798c52f414
MD5 d6f779166901c3904b8bff06ac4414b2
BLAKE2b-256 e92e9c5cc4a17ef46abaf9420617e25c5a5e11d0a881d442d1850a72cf808310

See more details on using hashes here.

File details

Details for the file flet_media_scanner-0.86.2-py3-none-any.whl.

File metadata

File hashes

Hashes for flet_media_scanner-0.86.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2675c78e2afe12b681940473e531f77d9bccb428a98e063c6b61f27d17feea4c
MD5 6cf355ff855c5fc7a649728d50c4a8ba
BLAKE2b-256 60c4bad41f95cfc3ecea29d3ae9ac4fc73a1ec41f38d2739e0a2b3d0fae2f0f4

See more details on using hashes here.

Release history Release notifications | RSS feed

1.7.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.86.5

2 files

0.86.4

2 files

0.86.3

2 files

This release

0.86.2 This release

2 files

0.86.1

2 files

0.86.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page