admel_audio_ads 0.0.1 copy "admel_audio_ads: ^0.0.1" to clipboard
admel_audio_ads: ^0.0.1 copied to clipboard

A Flutter plugin for audio playback with banner display functionality

Plugin Test #

A Flutter plugin that provides cross-platform audio playback with banner display functionality for both iOS and Android platforms.

Features #

  • Audio Playback: Stream audio from URLs with full playback control
  • Banner Display: Show customizable banners with progress indicators during audio playback
  • Volume Monitoring: Automatic detection of device mute state with mute notification banners
  • Cross-Platform: Native implementations for both iOS (Objective-C) and Android (Kotlin)
  • Customizable Positioning: Flexible banner positioning with offset support
  • Click-to-Action: Banners can open URLs when tapped
  • Progress Visualization: Real-time progress rings around banners
  • Volume Control: System volume control integration

Platform Support #

Platform Implementation Language
iOS Native Objective-C
Android Native Kotlin

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  plugin_test:
    path: ../

Usage #

Basic Setup #

import 'package:plugin_test/plugin_test.dart';

final _pluginTest = PluginTest();

// Initialize the plugin
await _pluginTest.initializePlugin(
  muteBannerUrl: 'https://example.com/mute-banner.png',
  size: 80.0,
  position: 'bottom-right',
  offsetX: 0.0,
  offsetY: 0.0,
);

Play Audio with Banner #

await _pluginTest.playAudioWithBanner(
  audioPath: 'https://example.com/audio.mp3',
  bannerUrl: 'https://example.com/banner.png',
  size: 80.0,
  position: 'bottom-left',
  offsetX: 50.0,
  offsetY: -30.0,
  targetUrl: 'https://example.com',
);

Control Playback #

// Stop audio and hide banner
await _pluginTest.stopAudioAndHideBanner();

// Check if playing
bool isPlaying = await _pluginTest.isPlaying();

// Get playback information
double currentPosition = await _pluginTest.getCurrentPosition();
double duration = await _pluginTest.getDuration();
double progress = await _pluginTest.getProgress();

Volume Control #

// Get current volume (0.0 to 1.0)
double volume = await _pluginTest.getCurrentVolume();

// Set volume
await _pluginTest.setVolume(0.5);

API Reference #

PluginTest #

Methods

initializePlugin({...})

Initialize the plugin with mute banner configuration.

Parameters:

  • muteBannerUrl (String?): URL for the mute notification banner image
  • size (double): Size of the banner in pixels (default: 80.0)
  • position (String): Position of the banner (default: 'bottom-right')
  • offsetX (double): X offset from the base position (default: 0.0)
  • offsetY (double): Y offset from the base position (default: 0.0)
playAudioWithBanner({...})

Play audio with banner display.

Parameters:

  • audioPath (String, required): URL or path to the audio file
  • bannerUrl (String?): URL for the banner image
  • size (double): Size of the banner in pixels (default: 80.0)
  • position (String): Position of the banner (default: 'bottom-right')
  • offsetX (double): X offset from the base position (default: 0.0)
  • offsetY (double): Y offset from the base position (default: 0.0)
  • targetUrl (String?): URL to open when banner is tapped
stopAudioAndHideBanner()

Stop audio playback and hide banner.

stopAudio()

Stop audio playback only (banner remains visible).

isPlaying()

Check if audio is currently playing.

Returns: Future<bool>

getCurrentPosition()

Get current audio position in seconds.

Returns: Future<double>

getDuration()

Get audio duration in seconds.

Returns: Future<double>

getProgress()

Get playback progress as a value between 0.0 and 1.0.

Returns: Future<double>

getCurrentVolume()

Get current system volume as a value between 0.0 and 1.0.

Returns: Future<double>

setVolume(double volume)

Set system volume.

Parameters:

  • volume (double): Volume level between 0.0 (mute) and 1.0 (maximum)

The plugin supports the following banner positions:

  • 'top-left': Top-left corner of the screen
  • 'top-right': Top-right corner of the screen
  • 'bottom-left': Bottom-left corner of the screen
  • 'bottom-right': Bottom-right corner of the screen (default)
  • 'center': Center of the screen
  • 'custom': Custom position using only offsetX and offsetY values

Features in Detail #

Audio Playback #

  • Supports streaming audio from URLs
  • Automatic audio session management
  • Background playback support
  • Error handling for network issues
  • Customizable size and position
  • Progress ring visualization
  • Smooth slide-in/slide-out animations
  • Click-to-action functionality
  • Image loading from URLs

Mute Detection #

  • Automatic volume monitoring
  • Mute state detection
  • Automatic mute notification banner display
  • Configurable mute banner appearance

Volume Control #

  • System volume integration
  • Real-time volume monitoring
  • Cross-platform volume control

Platform-Specific Implementation #

iOS (Objective-C) #

  • Uses AVAudioPlayer for audio playback
  • MPVolumeView for volume control
  • UIView animations for banner transitions
  • Volume change notifications
  • Safe area support

Android (Kotlin) #

  • Uses MediaPlayer for audio playback
  • AudioManager for volume control
  • Custom ProgressRingView with rectangular border progress visualization starting from 12 o'clock position
  • Clockwise progress animation synchronized with audio playback progress
  • Glide for image loading
  • Material Design animations
  • PathMeasure-based progress drawing for smooth rectangular progress indication
  • Detailed logging for progress tracking and debugging

Permissions #

Android #

The plugin requires the following permissions in your android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

iOS #

No additional permissions required. The plugin uses standard audio playback APIs.

Example #

See the example/ directory for a complete example application demonstrating all plugin features.

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

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Technical Notes #

Architecture #

The plugin follows Flutter's federated plugin architecture:

  • lib/plugin_test_platform_interface.dart: Platform interface definition
  • lib/plugin_test_method_channel.dart: Method channel implementation
  • lib/plugin_test.dart: Public API
  • ios/Classes/: iOS native implementation
  • android/src/main/kotlin/: Android native implementation

Error Handling #

The plugin includes comprehensive error handling for:

  • Network connectivity issues
  • Invalid audio URLs
  • Permission errors
  • Platform-specific audio system errors

Performance #

  • Efficient memory management for audio playback
  • Optimized image loading and caching
  • Smooth animations with proper cleanup
  • Background processing for volume monitoring
1
likes
150
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for audio playback with banner display functionality

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on admel_audio_ads

Packages that implement admel_audio_ads