ogplayer_flutter 1.3.1
ogplayer_flutter: ^1.3.1 copied to clipboard
OGPlayer — a full-featured video player SDK for Flutter. HLS/DASH, DRM, IMA ads, offline downloads, playlists, picture-in-picture and a fully customizable native player UI.
OGPlayer Flutter #
The OGPlayer video player for Flutter.
Release notes: https://ogplayer.tv/docs/reference/changelog/
ogplayer_flutter is a thin platform-view wrapper over the OGPlayer native
playback engine. Rendering, playback, DRM, ads and the player chrome are 100%
native; this package adds a typed Dart API and an OGPlayerView widget.
import 'package:ogplayer_flutter/ogplayer_flutter.dart';
AspectRatio(
aspectRatio: 16 / 9,
child: OGPlayerView(
source: const OGMediaItem(
url: 'https://cdn.example.com/master.m3u8',
title: 'My stream',
),
onStateChanged: (state) => debugPrint('$state'),
),
)
Features #
VOD, live and live-DVR · multi-DRM (Widevine / FairPlay) with a Dart
tokenProvider called on every license request · Google IMA ads ·
playlists with a themeable "Up next" card · a swipeable vertical video feed
(OGVerticalFeedView) · offline downloads with offline
DRM (OGDownloads) · picture-in-picture · embedded + sideloaded subtitles,
multi-audio, quality selection · full native player chrome (configurable
down to headless, with your own action icons by name) · watermark overlays
in nine anchored slots · posters, content ratings, custom error copy and
styling · one event stream for every playback, ad and analytics callback.
Not yet available: FreeWheel ads.
The vertical feed is a portrait surface. On Android it pins the activity
portrait while mounted and restores your app's own orientation on unmount
(large-screen devices ignore orientation pins by platform policy). On iOS it
follows your app's interface-orientation mask: with the plugin's AppDelegate
hook in place (see the iOS requirements below) the app is portrait outside
player fullscreen, so the feed is too — an app that allows landscape will
rotate the feed.
Install #
flutter pub add ogplayer_flutter
On Android the playback engine resolves from Maven Central; on iOS through Swift Package Manager (the frameworks also ship inside this package for CocoaPods projects).
Requirements #
-
Flutter 3.29+
-
Android: minSdk 26, and your
MainActivitymust extendFlutterFragmentActivity(the player UI needs an androidx lifecycle owner; picture-in-picture needs a ComponentActivity):import io.flutter.embedding.android.FlutterFragmentActivity class MainActivity : FlutterFragmentActivity() -
Android: core-library desugaring enabled (Media3 requirement) — in
android/app/build.gradle.kts:compileOptions { isCoreLibraryDesugaringEnabled = true } dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5") } -
Android +
pipEnabled: addandroid:supportsPictureInPicture="true"to your activity in the app manifest. -
Android +
castEnabled: declare the Cast options provider in your app manifest —<meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:value="com.ogplayer.cast.OGCastOptionsProvider"/> -
Android + icon names (
CustomActionConfig.iconName,OverlayConfig.imageName, icon-name overrides): these resolve app drawables by name at runtime, which Flutter's default release build would strip (resource shrinking can't see runtime lookups). Prefix the drawable names withog_(e.g.og_action_share) and the plugin's bundled shrinker rule keeps them automatically — nothing to configure. For names you can't prefix, add your ownandroid/app/src/main/res/raw/keep.xmlwithtools:keep="@drawable/my_icon". -
iOS: 18.0+ (iPhone XS/XR 2018 and newer)
-
iOS + fullscreen rotation: declare landscape orientations in your
Info.plistand forwardsupportedInterfaceOrientationsFortoOgplayerFlutterPlugin.interfaceOrientationMaskin yourAppDelegate(two lines — see the example app). Without it the player stays embedded. -
iOS +
pipEnabled: addUIBackgroundModes: audioto yourInfo.plist. -
iOS +
OGDownloads: downloads that finish while the app isn't running relaunch it in the background — forwardapplication(_:handleEventsForBackgroundURLSession:completionHandler:)toOgplayerFlutterPlugin.handleDownloadBackgroundEventsin yourAppDelegate(see the example app).
Controlling playback #
Commands go through the controller handed to onViewCreated:
OGPlayerViewController? player;
OGPlayerView(
source: item,
onViewCreated: (c) => player = c,
);
// later
player?.pause();
player?.seekTo(30000);
player?.enterFullscreen();
Docs #
Full guides and the API reference: https://ogplayer.tv/docs
License #
OGPlayer is commercial software — free to evaluate (the player renders an OGPlayer watermark); production use requires a license key. See LICENSE · https://ogplayer.tv/terms/ · sales@ogplayer.tv