AdMel WebView SDK for Flutter
WebView integration for AdMel SDK with automatic BGM ducking support.
When an audio ad plays, the SDK automatically lowers the volume of <audio> elements in your WebView and restores it when the ad finishes.
Installation
dependencies:
admel_webview_sdk: ^1.0.0
admel_sdkis included as a transitive dependency — no need to add it separately.
Quick Start
import 'package:admel_sdk/admel_sdk.dart';
import 'package:admel_webview_sdk/admel_webview_sdk.dart';
// 1. Initialize AdMel SDK
final admelSdk = AdMelSdk();
await admelSdk.setMediaId('YOUR_MEDIA_ID');
await admelSdk.initialize(AdMelEnvironment.production);
// 2. Create WebView SDK (BGM ducking is enabled by default)
final webViewSdk = AdMelWebViewSdk(admelSdk: admelSdk);
// 3. Create a WebViewController with autoplay enabled
final controller = AdMelWebViewHelper.createController();
webViewSdk.setWebViewController(controller);
// 4. Load your web content
await controller.loadRequest(Uri.parse('https://your-game.example.com'));
// 5. Show ad — BGM ducking happens automatically
await admelSdk.showAd('YOUR_SLOT_ID', position: 'bottom-right');
BGM Ducking
BGM ducking is enabled by default with volume 0.2 (20%).
// Customize ducking volume
webViewSdk.enableBgmDucking(volume: 0.3);
// Disable ducking
webViewSdk.disableBgmDucking();
// Manual BGM control (e.g., when navigating away)
webViewSdk.pauseBgm();
webViewSdk.resumeBgm();
License
MIT