bmdrm_plugin 0.0.2 copy "bmdrm_plugin: ^0.0.2" to clipboard
bmdrm_plugin: ^0.0.2 copied to clipboard

A Flutter plugin for DRM-protected video playback with watermark support.

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 watermark
  • type: Either 'static' or 'dynamic'
  • name: Display name for the watermark
  • text: The text to display
  • alpha: Opacity (0.0 to 1.0)
  • color: Hex color code (e.g., '#FFFFFF')
  • size: Font size in pixels
  • interval: Animation interval in milliseconds (for dynamic watermarks)
  • skip: Number of intervals to skip
  • x, y: Position as percentage of video dimensions

DRM Session Data #

The DrmSessionData class contains:

  • edgeName: DRM edge server name
  • token: Session authentication token
  • ecdsaKey: ECDSA signing key for URL signing
  • drmServerUrl: License server URL
  • kid: 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-exoplayer
  • androidx.media3:media3-ui
  • androidx.media3:media3-datasource
  • androidx.media3:media3-common
  • androidx.media3:media3-session
  • androidx.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 #

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support #

For support, please open an issue on GitHub or contact the development team.

0
likes
115
points
150
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for DRM-protected video playback with watermark support.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

crypto, flutter, http, plugin_platform_interface, pointycastle

More

Packages that depend on bmdrm_plugin

Packages that implement bmdrm_plugin