[F/OS] Media3Player: a modern video and audio player extension (ExoPlayer v3)

Media3 Ă— App Inventor

Introduction

Media3Player is an open source video and audio player for App Inventor, built on AndroidX Media3, the current version of ExoPlayer. It replaces my older ExoPlayer extension with a modern player UI and a much larger set of blocks.

It plays files and streams (MP4, HLS, DASH, SmoothStreaming, RTSP, live streams and internet radio), protected content with Widevine, ClearKey and PlayReady, and downloads for offline playback. You get a ready player with gestures, fullscreen and a settings sheet, or you can turn the controls off and build your own UI with blocks.

Features

  • Player UI: auto-hiding controls, a seek bar with buffering, chapters and thumbnail previews, previous and next, ±10s, a speed chip, subtitles and a settings sheet (quality, speed, subtitles, audio track, zoom, loop).
  • Gestures: double tap to seek, hold for 2Ă— speed, pinch to zoom, swipe for brightness and volume in fullscreen. Each one can be turned off.
  • Fullscreen in landscape or portrait, matching the video, and D-pad and remote navigation.
  • Formats: MP4, HLS, DASH, SmoothStreaming and RTSP, live streams with a LIVE indicator, custom HTTP headers, and WebVTT, SRT, TTML and SSA subtitle files.
  • DRM: Widevine, ClearKey and PlayReady, including ClearKey from known keys without a license server.
  • Media items: describe each media and how to play it in one dictionary, with keys from dropdowns. Build playlists with blocks, or load them straight from JSON.
  • Queue: add, insert, replace, remove and move media, with an up next countdown, replay, and error and retry states.
  • Background playback with a media notification, lock screen and headset controls.
  • Offline: downloads with progress events, a disk cache for streams, and preloading of the next media.
  • Audio: equalizer presets and bands, bass boost, loudness boost, mono and left/right balance.
  • Customization: accent and control colors, corner radius, poster image, subtitle style, and a switch for each control.
  • Events and data: playback state, position, buffering, tracks, video size, stream titles from internet radio, errors by category, playback statistics, the current subtitle text, and the phone's media volume.
  • Other: frame capture to PNG, a dialog mode, moving the player between arrangements, and several players on one screen.

Screenshots

Fullscreen Settings sheet
Fullscreen playback Settings sheet
Inline player Thumbnails while scrubbing
Inline player Thumbnail preview

Getting started

  1. Import dev.dreamerslab.media3.aix (Palette → Extension → Import extension).
  2. Add an arrangement, for example a VerticalArrangement with Width Fill parent and a fixed Height, and a Media3Player component.
  3. In Screen1.Initialize, call Media3Player1.Create(VerticalArrangement1).
  4. Call Play(source, title), and AddToQueue(source, title) for more media. A source is a URL or the name of a media file uploaded to the project.
  5. Build an APK to test. The AI Companion can't load the Media3 libraries the extension ships, so the player doesn't work in it.

How it works

The player lives in an arrangement. Create puts it inside the arrangement you give it, and MoveTo, EnterFullscreen and ShowAsDialog move it around. Most settings are properties you can set in the designer.

Media items describe what to play. For anything beyond a URL and a title, like subtitles, DRM, a clip or thumbnails, pass a media item: a dictionary built with make a dictionary, whose keys come from dropdowns, so field names can't be misspelled. Only the uri is required.

Media items built with dictionary blocks

There's one dropdown for each part of a media item, named after Media3's classes:

Dropdown Fields
MediaItemField Uri, Title, Artist, Description, ArtworkUri, MimeType, DrmConfiguration, SubtitleConfigurations, ClippingConfiguration, Thumbnails
DrmConfigurationField Scheme, LicenseUri, LicenseRequestHeaders, ClearKeys
SubtitleConfigurationField Uri, Language, Label
ClippingConfigurationField StartPositionMs, EndPositionMs
ThumbnailsField Uri, Columns, Rows, IntervalMs

A playlist decoded from JSON with Web.JsonTextDecodeWithDictionaries works as it is, with the field names as text keys (uri, title, drmConfiguration…).

Results arrive in events. Playback changes fire events like PlaybackStateChanged, MediaChanged and PlayerError, with an error category (Network, NotFound, Format, Decoder, DRM or Other). Mistakes in blocks, like an index outside the queue or a misspelled media item field, raise Screen.ErrorOccurred with an error number and a message naming the problem.

Blocks

Media3Player has 247 blocks. The block reference shows every one with its image and description, grouped like the designer: functions, events, properties and dropdowns. Each image contains its block, so you can drag it straight into your workspace.

Blocks in use

These come from the sample project.

Screen1-Initialize
Show the player and play a queue of media items: MP4 with subtitles and thumbnails, HLS, a clipped DASH stream, SmoothStreaming, Widevine and ClearKey DRM, a live stream and internet radio.

Media3Player1-MediaChanged
Show what's playing when the queue moves on.

Media3Player1-StreamTitleChanged
Show the song an internet radio station is playing.

Media3Player1-PlayerError
Tell the user why a media can't play.

PauseButton-Click
Your own controls, next to or instead of the player's.

ShowItemButton-Click
Read the current media item back as a dictionary.

Sample project

Media3Sample.aia plays a queue with every kind of media, built with media items, and has buttons for previous, pause, resume, next and showing the current media item. Import it (My Projects → Import project) and build an APK to try it.

Requirements and testing

  • Android 6.0 (API 23) or newer. CaptureFrame needs Android 7.0. The extension adds about 12 MB to your app.
  • Test with an APK build: the AI Companion can't load the Media3 libraries the extension ships.
  • Tested with MIT App Inventor (nb206) in compiled apps on a Pixel 7a and a vivo V2332 (Android 16).
  • Kodular: builds failed before 3.1.0 with "Could not merge resources". Since 3.1.0 the extension passes the same resource merge Kodular uses, but I haven't built it on Kodular's servers yet, so I'd love to hear your results.
  • Google Play: for background playback and downloads, the extension declares two foreground services, media playback and data sync. Play Console asks you to explain them under App content → Foreground service permissions.

Changelog

View

3.3.0: two more media item settings from the old ExoPlayer extension.

  • RequestHeaders: HTTP headers for one media, on top of SetHeader's, for media that need their own tokens or keys.
  • LiveConfiguration: how close to the live edge a live stream plays (TargetOffsetMs, MinOffsetMs, MaxOffsetMs, MinPlaybackSpeed, MaxPlaybackSpeed). It overrides TargetLiveOffset for that media.

3.2.0 (2026-10-14)

  • Media items: describe each media in one dictionary with keys from dropdowns, with SetMediaItems, AddMediaItem, AddMediaItems, ReplaceMediaItem, GetMediaItemAt and blocks to change part of a queued item.
  • The blocks that change the most recently added media (AddSubtitle, ClipMedia, SetDrm, SetClearKeys, SetMediaType, SetMetadata, SetThumbnails, SetThumbnailTrack) are deprecated: hidden from the drawer, still working in existing projects.
  • Fixes: the settings sheet was partly hidden by the navigation bar on Android 15+; PositionUpdateInterval fired IsPlayingChanged; BandLevel with a missing band stopped the app; toggle switch animations.
  • A sample project with a queue of every kind of media.

3.1.1 (2026-10-14)

  • Pause and SeekTo are back; they were missing by mistake in 3.0.0 and 3.1.0.
  • New: the PlaybackState property, and RepeatModeChanged and ShuffleModeEnabledChanged events.

3.1.0 (2026-10-13)

  • Fixes "Could not merge resources" on Kodular, by building with Rush 2.5.
  • ClearKey DRM from known keys, without a license server.
  • D-pad and remote navigation.
  • When a video decoder fails to start, the next one is tried.
  • Events fired while the app starts, such as from designer properties, are no longer lost.

3.0.0 (2026-10-12)

  • First release of the Media3 version.

Downloads

Built with Rush

Media3 ships as Android libraries (AARs) with their own resources. The extension is built with Rush, the open source extension builder I maintain, which packs them into the extension as real AARs, so App Inventor's build server compiles their resources into your app. It's a good example if you want to build an extension on AndroidX libraries yourself.

Credits and APIs

Android, ExoPlayer and Media3 are trademarks of Google, and MIT App Inventor of MIT; this is a community project, not an official one.

Price and license

The extension is free. It's open source under MPL-2.0: you can use it in any app, free or commercial, and your app's code stays yours. If you change the extension itself and share it, those changes stay open under the same license.

What's next

Next up is a tested Kodular build and a Kodular sample project (#1, #2). Questions, bug reports and ideas are very welcome, here or as GitHub issues.


FAQ
  • AI Companion: not supported, the Companion can't load Media3's libraries. Build an APK.
  • YouTube and Google Drive links: not media URLs. A YouTube page isn't a media file, and playing YouTube outside its official players is against its terms. For Drive, use a direct download link.
  • Casting, ads and picture-in-picture: not possible for extensions. Casting and IMA ads need Google Play Services setup App Inventor doesn't provide, and picture-in-picture needs a setting on the screen's activity.
  • MKV files you can't seek: the file has no seek index; remux it (ffmpeg -i in.mkv -c copy out.mkv).
  • A video that doesn't play: codecs like HEVC 10-bit, AC-3 and DTS depend on the phone. PlayerError with category Decoder or Format means the device can't decode the file.
  • Several players: players pause when other audio starts, including another player in the app. Turn AudioFocus off on players that should play on their own.
5 Likes

Unable to import the aia & extension :neutral_face: .

Did you get an error? Anything useful to debug the issue. For me, it works fine in AI2.

“Upload error” is showing while trying to upload.

Screenshot 2026-10-13 022228

Are you using AI2 builder? I tested the aia file on AI2 builder.

I believe the Upload Error is a problem with AI2. Investigating...

Try restarting AI2 in your browser if you get this message, the aia project should be loaded and openable / working.

1 Like

Works fine here with the APK.
Companion fails.

See this

1 Like

Media3Player 3.2.0 is out :tada:

New: media items. Describe each media and how to play it (subtitles, DRM, clipping, thumbnails, artwork) in one dictionary, with keys from dropdowns so names can't be misspelled. Build playlists with blocks, or load them straight from JSON with Web.JsonTextDecodeWithDictionaries. New blocks: SetMediaItems, AddMediaItem, AddMediaItems, ReplaceMediaItem, GetMediaItemAt, plus blocks that change part of a queued item.

Deprecated: AddSubtitle, ClipMedia, SetDrm, SetClearKeys, SetMediaType, SetMetadata, SetThumbnails and SetThumbnailTrack. They still work in existing projects but are hidden from the drawer; use media items instead.

Fixes:

  • The settings sheet was partly hidden by the navigation bar on Android 15+.
  • PositionUpdateInterval fired IsPlayingChanged.
  • BandLevel with a missing band stopped the app.
  • Toggle switches animated every time the settings sheet opened.

New sample project: a queue with every kind of media (MP4 with subtitles and thumbnails, HLS, DASH, SmoothStreaming, Widevine, ClearKey, a live stream and internet radio).

Also since 3.0.0:

  • 3.1.1: Pause and SeekTo are back, plus a PlaybackState property and RepeatModeChanged/ShuffleModeEnabledChanged events.
  • 3.1.0:
    • fixes "Could not merge resources" on Kodular;
    • ClearKey DRM from known keys;
    • D-pad and remote navigation;
    • decoder fallback;
    • startup events are no longer lost.

Download: latest release (extension and sample project). Every block is documented, with images you can drag into your workspace, in the block reference.

Kodular users: if you try it, please tell me whether it builds for you.

Media3Player 3.3.0: two more media item settings from the old ExoPlayer extension.

  • RequestHeaders: HTTP headers for one media, on top of SetHeader's, for media that need their own tokens or keys.
  • LiveConfiguration: how close to the live edge a live stream plays (TargetOffsetMs, MinOffsetMs, MaxOffsetMs, MinPlaybackSpeed, MaxPlaybackSpeed). It overrides TargetLiveOffset for that media.
1 Like

Awesome :heart::heart::heart: