DEV Community

Cover image for flet-media-library — Real Device Media Access for Flet (Android + iOS)
Faizan gondal
Faizan gondal

Posted on

flet-media-library — Real Device Media Access for Flet (Android + iOS)

I’ve been building Flet apps for a while now, and one thing that kept frustrating me was media.


Want to show the user’s actual photos and videos?

Want to save a recording or a downloaded video so it actually appears in the Gallery / Photos app?

Want to do it without requesting the nuclear MANAGE_EXTERNAL_STORAGE permission?

Until recently the answer was basically “good luck”.

So I built flet-media-library.

It’s a proper Flet service that gives you full, modern access to the device media library on both Android and iOS — from pure Python.

Repo: https://github.com/fazi-gondal/Flet-media-library

PyPI: pip install flet-media-library

Current version: 1.1.2

What it actually does

  • Query albums and paginate through photos, videos, and audio
  • Generate thumbnails (base64 or file path — your choice)
  • Save images, videos, and audio directly into the public folders (DCIM/, Pictures/, Movies/, Music/)
  • Rename, move, copy, and delete assets
  • Get real-time change notifications when the user adds or deletes media outside your app
  • Handles the messy modern permission model (Android 13+ granular permissions + iOS limited access) correctly

And the important part: it never asks for all-files access. It plays nicely with Google Play and the App Store.

Quick example

import flet as ft
from flet_media_library import MediaLibrary

async def main(page: ft.Page):
    media = MediaLibrary()
    page.services.append(media)
    page.update()

    status = await media.request_permissions(["image", "video"])
    if not (status.all_granted or status.any_limited):
        page.add(ft.Text("Need media permission"))
        return

    result = await media.get_assets(media_type="image", limit=40)

    grid = ft.GridView(expand=True, max_extent=110, spacing=4, run_spacing=4)
    for asset in result.items:
        thumb = await media.get_thumbnail(asset.id, width=110, height=110)
        grid.controls.append(
            ft.Image(src_base64=thumb, fit=ft.BoxFit.COVER, border_radius=6)
        )

    page.add(grid)

ft.run(main)
Enter fullscreen mode Exit fullscreen mode

That’s real gallery access in under 30 lines.

Why I built the custom Android bits

photo_manager (the Flutter package under the hood) is excellent, but it doesn’t cover everything I needed:

  • Saving audio files into the Music/ directory
  • Renaming assets in-place
  • Moving assets between folders

So I wrote a small Kotlin fallback for those three operations. Everything else stays in the well-maintained photo_manager path. Clean separation, no unnecessary native code.

Try it without building anything

There’s a pre-built demo APK on the GitHub releases page.

Install it, grant permission, and you can immediately test the gallery, camera capture → save, audio recording → Music folder, rename/move/delete, and the live change events.

Who this is for

Anyone building Flet apps that deal with media:

  • Gallery / photo picker apps
  • Camera or screen-recording apps
  • Voice recorders
  • Video downloaders
  • Social-style apps that need to save content to the device

If you’ve been avoiding proper media features in Flet because the platform side felt too painful, this should remove that blocker.

Links

I’m actively maintaining it. Issues and PRs are welcome.

If you’re working on something media-related with Flet, give it a spin and let me know how it goes.

Top comments (0)