A wrapper for Bunny.net mobile SDK for Android & iOS
This plugin currently provides:
- Bunny Stream data/API calls via
BunnyStreamFlutter - Native built-in Bunny player widget via
BunnyBuiltInPlayerView
Available features
API features
- Initialize Bunny credentials and defaults via
initialize - Fetch paginated videos via
listVideos - Fetch single video metadata via
getVideo - Generate playback links (HLS + fallback + renditions) via
getVideoPlayData - Optional tokenized playback URL generation (
token,expires) - Typed models:
BunnyVideo,BunnyCollection,BunnyVideoPlayData - Unified platform error mapping through
BunnyStreamException
Player features
- Native built-in Bunny player widget:
BunnyBuiltInPlayerView - Android and iOS platform view integration
- Secure playback inputs supported in widget API (
token,expires)
Current native method support status
- Implemented natively on Android and iOS:
initialize,listVideos,getVideo,getVideoPlayData - Not yet implemented natively:
listCollections,getCollection
Requirements
- Flutter
>=3.38.4 - Dart
^3.10.3 - Android
minSdk 26 - iOS
15.0+
Quick start (API)
import 'package:bunny_stream_flutter/bunny_stream_flutter.dart';
final bunny = BunnyStreamFlutter();
await bunny.initialize(
accessKey: 'YOUR_STREAM_ACCESS_KEY',
libraryId: 12345,
cdnHostname: 'vz-12345.b-cdn.net',
);
final playData = await bunny.getVideoPlayData(
libraryId: 12345,
videoId: 'VIDEO_GUID',
token: 'OPTIONAL_SECURE_TOKEN',
expires: 1735689600,
);
print(playData.playlistUrl);
Quick start (built-in player)
import 'package:bunny_stream_flutter/bunny_stream_flutter.dart';
SizedBox(
height: 260,
child: BunnyBuiltInPlayerView(
accessKey: 'YOUR_STREAM_ACCESS_KEY',
videoId: 'VIDEO_GUID',
libraryId: 12345,
token: 'OPTIONAL_SECURE_TOKEN',
expires: 1735689600,
isPortrait: false,
isScreenShotProtectEnable: false,
),
)
User-side setup required
Android
Apply the following in your app project (the app that consumes this plugin):
- Add JitPack repository in your top-level
android/build.gradleorandroid/build.gradle.kts:
allprojects {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
}
-
Ensure
minSdkis at least26in your app module. -
Use an AppCompat-based app/activity theme (required by Bunny native UI):
<application
...
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
- Ensure your Flutter activity themes are AppCompat too (
LaunchTheme/NormalThemeinstyles.xml):
<style name="LaunchTheme" parent="@style/Theme.AppCompat.Light.NoActionBar" />
<style name="NormalTheme" parent="@style/Theme.AppCompat.Light.NoActionBar" />
- Add ProGuard/R8 rule in
android/app/proguard-rules.pro:
-keep class net.bunny.bunnystreamplayer.** { *; }
- Keep internet permission enabled in manifest:
<uses-permission android:name="android.permission.INTERNET" />
iOS
Apply the following in your iOS app project:
-
Ensure iOS deployment target is
15.0or higher (Podfile + Xcode target). -
Enable Swift Package Manager support in Flutter toolchain:
flutter config --enable-swift-package-manager
- Add Bunny iOS SDK package in Xcode (required):
- Open
ios/Runner.xcworkspacein Xcode - Go to
Runner→Package Dependencies→+ - Search for
bunny-stream-iosin the package manager - Select
bunny-stream-iosfrom results - Click Add to Project and choose
Runner - Select the branch/version you want
- Click Add Package
- Ensure product
BunnyStreamPlayerandBunnyStreamApiis linked toRunnertarget
- Refresh iOS dependencies:
flutter clean
flutter pub get
cd ios && pod install
- Verify package linkage:
flutter config --listshould includeenable-swift-package-manager: true- In Xcode,
Runnershould showbunny-stream-iosunder Package Dependencies - Ensure no iOS build errors for missing
BunnyStreamPlayer
Troubleshooting iOS
Check this: https://github.com/BunnyWay/bunny-stream-ios?tab=readme-ov-file#troubleshooting
FlutterGeneratedPluginSwiftPackage resets to iOS 13.0 after pod install
ios/Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage/Package.swift is generated by Flutter tooling.
If you run only pod install, it may still show:
platforms: [
.iOS("13.0")
]
Run Flutter iOS config generation so Flutter updates the generated package platform from your project deployment target:
flutter clean
flutter pub get
flutter build ios --config-only --simulator
cd ios && pod install --repo-update
Also ensure all iOS deployment targets in your app project are 15.0+ (Podfile + Xcode target/build settings).
Required Bunny values
libraryIdaccessKeyvideoId- Optional
cdnHostname - Optional
tokenandexpires(recommended from backend for secured playback)
Security notes
- Do not hardcode production access keys in client apps.
- Generate
token/expiresserver-side for protected playback. - Keep secrets on backend whenever possible.
API reference
Public entrypoint: BunnyStreamFlutter
initialize
Future<void> initialize({
required String accessKey,
required int libraryId,
String? cdnHostname,
String? token,
int? expires,
})
listVideos
Future<List<BunnyVideo>> listVideos({
required int libraryId,
int page = 1,
int itemsPerPage = 100,
String? search,
String? collectionId,
})
getVideo
Future<BunnyVideo> getVideo({
required int libraryId,
required String videoId,
})
listCollections
Future<List<BunnyCollection>> listCollections({
required int libraryId,
int page = 1,
int itemsPerPage = 100,
String? search,
})
getCollection
Future<BunnyCollection> getCollection({
required int libraryId,
required String collectionId,
})
getVideoPlayData
Future<BunnyVideoPlayData> getVideoPlayData({
required int libraryId,
required String videoId,
String? token,
int? expires,
})
SDK references
- Bunny Stream API docs: https://docs.bunny.net/api-reference/stream
- Bunny Android SDK: https://github.com/BunnyWay/bunny-stream-android
- Bunny iOS SDK: https://github.com/BunnyWay/bunny-stream-ios