BMDRM Plugin
A Flutter plugin for DRM-protected video playback with watermark support.
Features
- DRM Support: Supports Widevine, FairPlay, and PlayReady DRM systems
- Watermark Overlay: Dynamic and static watermark support with customizable positioning and styling
- Platform Optimized: Native Android implementation using ExoPlayer with Media3
- Cryptographic Security: Real ECDSA signature generation and ECDH key exchange
- Session Management: Automatic DRM session generation and management
- Error Handling: Comprehensive error handling and logging
- Code Obfuscation: Production-ready obfuscation support for both Android and iOS
Installation
Add this to your pubspec.yaml:
dependencies:
bmdrm_plugin: ^0.0.1
Usage
Basic Usage
import 'package:bmdrm_plugin/bmdrm_plugin.dart';
// Automatic DRM session generation
BmdrmVideoPlayer.drmMinimal(
apiKey: 'your-api-key',
userId: 'user-123',
videoId: 'video-456',
watermarkConfig: WatermarkConfig(
id: 'watermark-1',
type: 'static',
name: 'My Watermark',
text: 'Protected Content',
alpha: 0.8,
color: '#FFFFFF',
size: 16,
interval: 0,
skip: 0,
x: 10.0,
y: 10.0,
),
onPlay: () {},
onPause: () {},
onError: (error) {},
)
Pre-generated Session Data
// Using pre-generated DRM session data
BmdrmVideoPlayer.drmWithSession(
drmSessionData: DrmSessionData(
edgeName: 'edge-server',
token: 'session-token',
ecdsaKey: 'signing-key',
drmServerUrl: 'https://drm-server.com/license',
),
watermarkConfig: WatermarkConfig(...),
)
DRM Service Usage
// Generate DRM session
final sessionJson = await DartDrmService.generateSession(
apiKey: 'your-api-key',
userId: 'user-123',
videoId: 'video-456',
platform: 'Android',
);
// Parse session data
final sessionData = DartDrmService.parseSessionResponse(sessionJson);
// Generate stream URLs
final drmUrls = DartDrmService.generateDrmStreamUrls(
sessionData: sessionData,
streamType: 'widevine',
quality: 'h264',
);
Configuration
Watermark Configuration
The WatermarkConfig class supports the following properties:
id: Unique identifier for the watermarktype: Either 'static' or 'dynamic'name: Display name for the watermarktext: The text to displayalpha: Opacity (0.0 to 1.0)color: Hex color code (e.g., '#FFFFFF')size: Font size in pixelsinterval: Animation interval in milliseconds (for dynamic watermarks)skip: Number of intervals to skipx,y: Position as percentage of video dimensions
DRM Session Data
The DrmSessionData class contains:
edgeName: DRM edge server nametoken: Session authentication tokenecdsaKey: ECDSA signing key for URL signingdrmServerUrl: License server URLkid: Key ID (optional)certificateUrl: Certificate URL (optional)watermark: Embedded watermark configuration (optional)
Platform Support
- Android: Uses ExoPlayer with Media3 for optimal performance
- iOS: Uses AVPlayer with FairPlay DRM support
- Web: Uses video.js with EME support (planned)
Dependencies
The plugin requires the following dependencies:
dependencies:
crypto: ^3.0.3
http: ^1.1.0
pointycastle: ^3.7.3
video_player: ^2.8.1
Android Setup
The plugin automatically includes the necessary Android dependencies:
androidx.media3:media3-exoplayerandroidx.media3:media3-uiandroidx.media3:media3-datasourceandroidx.media3:media3-commonandroidx.media3:media3-sessionandroidx.media3:media3-exoplayer-drm
iOS Setup
For iOS, ensure you have the following in your ios/Podfile:
platform :ios, '12.0'
Example
See the example/ directory for a complete working example.
Building for Production
To build an obfuscated release:
cd example
flutter build apk --release --obfuscate --split-debug-info=build/debug-info
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Support
For support, please open an issue on GitHub or contact the development team.
Libraries
- bmdrm_player
- bmdrm_plugin
- BMDRM Plugin - A Flutter plugin for DRM-protected video playback with watermark support.
- bmdrm_plugin_method_channel
- bmdrm_plugin_platform_interface
- bmdrm_video_player
- dart_drm_service
- dart_drm_service_new
- utils/drm_logger
- watermark_overlay