Flutter quick start
ogplayer_flutter is a thin, typed plugin over the native OGPlayer SDKs
— the same Android artifacts and iOS frameworks native apps use. Rendering,
playback, DRM, ads and the player chrome never leave native code; the
package adds a Dart API, the OGPlayerView widget (a platform view) and one
event stream mirroring the native listeners.
Requires Flutter 3.29+ (Dart 3.7+).
Install
Section titled “Install”flutter pub add ogplayer_flutterAndroid resolves tv.ogplayer:* from the OGPlayer Maven repository, which
the plugin adds to your Gradle build — no repository setup needed. (If your
settings.gradle.kts sets a repositoriesMode such as
RepositoriesMode.FAIL_ON_PROJECT_REPOS or PREFER_SETTINGS, Gradle does not
take repositories from packages; add
maven("https://maven.ogplayer.tv") { content { includeGroup("tv.ogplayer") } }
to its dependencyResolutionManagement repositories.) Requirements in
your app (the playback engine needs them): minSdk 26, compileSdk 36,
Kotlin 2.1+, core-library desugaring, and a FlutterFragmentActivity host
(the player’s Compose chrome needs a lifecycle owner):
android { compileSdk = 36 defaultConfig { minSdk = 26 } compileOptions { isCoreLibraryDesugaringEnabled = true }}dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")}
// MainActivity.ktclass MainActivity : FlutterFragmentActivity()iOS resolves the OGPlayer frameworks through Swift Package Manager (the XCFrameworks also travel inside the package for CocoaPods hosts). iOS 18+.
Play something
Section titled “Play something”import 'package:ogplayer_flutter/ogplayer_flutter.dart';
AspectRatio( aspectRatio: 16 / 9, child: OGPlayerView( licenseKey: 'OGP2…', // omit → watermarked trial source: const OGMediaItem( url: 'https://example.com/stream.m3u8', title: 'My movie', posterUrl: 'https://example.com/poster.jpg', ), autoplay: true, autoFullscreenOnRotate: true, onStateChanged: (state) => debugPrint('$state'), onError: (error) => debugPrint('${error.code} ${error.message}'), ),)For fullscreen rotation on iOS, forward supportedInterfaceOrientationsFor
to OgplayerFlutterPlugin.interfaceOrientationMask in your AppDelegate
(and, for offline downloads, handleEventsForBackgroundURLSession to
OgplayerFlutterPlugin.handleDownloadBackgroundEvents) — a few lines, shown
in the demo app.
Same shape as every other platform — Widevine engages on Android, FairPlay
on iOS, and the tokenProvider (a plain Dart function) is called on every
license request, including silent renewals:
OGPlayerView( source: OGMediaItem( url: streamUrl, drm: DrmConfig( widevine: const WidevineConfig(licenseUrl: 'https://drm.example.com/widevine'), fairplay: const FairPlayConfig( licenseUrl: 'https://drm.example.com/fairplay', certificateUrl: 'https://drm.example.com/fairplay.cer', ), tokenHeaderName: 'X-DRM-Token', tokenProvider: (request) async => { 'X-DRM-Token': await freshToken(renewal: request.renewal), }, ), ),)Beyond the basics
Section titled “Beyond the basics”- Playlists — a
playlistparameter with per-item DRM/ads, auto-advance and the themeable Up next card (guide). - Vertical feed —
OGVerticalFeedViewrenders the swipeable portrait feed; on Android it pins the screen to portrait while mounted (guide). - Offline downloads —
OGDownloadsqueues, observes and plays back offline, DRM included (guide). - Ads — set
adsEnabledand putads: AdsConfig(adTagUrl: …)on the media item for Google IMA (guide). - Casting —
castEnabledplus one manifestmeta-dataentry on Android; AirPlay works out of the box on iOS. - Chrome — the full
OGUIConfigsurface: per-control visibility down to headless, the native color and dimension tokens (OGControlColors,OGControlDimens— guide), your own action icons by name, custom error copy and styling. - Localisation —
OGUIConfig(strings: OGStrings(…))puts every word and screen-reader label of the chrome in your language (guide). - Live —
controller.getLiveInfo()reads the DVR window, the distance behind the live edge and the playhead’s wall-clock time (guide). - Overlays — the
overlaysparameter places watermarks in the nine anchored slots.
Every native concept keeps its name and semantics, so the guides and the error-code table apply as-is.
Not yet in Flutter: FreeWheel ads — use the native Android/iOS SDKs if you need FreeWheel today.