Skip to content

QuangNH0606/wave_player

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

27 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Wave Player

A Flutter package for audio waveform visualization and playback with customizable UI components.

๐Ÿ“ฆ Package: wave_player on pub.dev

pub package

Demo

Screenshot Recording 1 Recording 2

Features

  • ๐ŸŽต Waveform Player โ€” Complete audio player with real-time waveform visualization
  • ๐ŸŽฎ Controller โ€” Programmatic control via WaveformPlayerController
  • ๐ŸŽš๏ธ Audio Slider โ€” Standalone waveform slider with multiple thumb shapes
  • ๐ŸŽจ Theming โ€” Full color customization and global theme support
  • โœจ Glow Effect โ€” Animated glow rings on the play/pause button
  • ๐Ÿ”„ Audio Manager โ€” Singleton for coordinated playback (auto-pause other players)

Installation

dependencies:
  wave_player: ^0.0.5
flutter pub get

Quick Start

From URL

import 'package:wave_player/wave_player.dart';

WaveformPlayer(
  audioUrl: 'https://example.com/audio.mp3',
)

From Asset

WaveformPlayer(
  assetPath: 'assets/audio/sample.mp3',
)

With Controller

final controller = WaveformPlayerController();

// Widget
WaveformPlayer(
  audioUrl: 'https://example.com/audio.mp3',
  controller: controller,
)

// Programmatic control
await controller.play();
await controller.pause();
await controller.togglePlayPause();
await controller.seekTo(Duration(seconds: 30));
await controller.seekToPercentage(0.5);

// Read state
controller.isPlaying;    // bool
controller.position;     // Duration
controller.duration;     // Duration
controller.isLoading;    // bool
controller.hasError;     // bool

Customization

WaveformPlayer(
  audioUrl: 'https://example.com/audio.mp3',

  // Waveform
  waveformHeight: 32.0,
  barWidth: 3.0,
  barSpacing: 2.0,
  activeColor: Colors.blue,
  inactiveColor: Colors.grey[300],

  // Thumb
  thumbSize: 20.0,
  thumbShape: ThumbShape.verticalBar, // .circle, .roundedBar
  thumbColor: Colors.blue,

  // Play button
  showPlayButton: true,
  playButtonSize: 48.0,
  playButtonColor: Colors.blue,
  playButtonIconColor: Colors.white,
  // Custom icons:
  playIconWidget: Icon(Icons.play_arrow),
  pauseIconWidget: Icon(Icons.pause),
  // Or animated icon:
  animatedIcon: AnimatedIcons.play_pause,
  iconSize: 24.0,

  // Glow effect
  showGlow: true,
  glowColor: Colors.blue,
  glowCount: 2,
  glowRadiusFactor: 0.25,
  glowDuration: Duration(milliseconds: 1000),

  // Display
  showDuration: true,
  durationTextStyle: TextStyle(fontSize: 12),
  backgroundColor: Colors.white,
  autoPlay: false,

  // Callbacks
  onPlayPause: (isPlaying) => print('Playing: $isPlaying'),
  onPositionChanged: (position) => print('Position: $position'),
  onCompleted: () => print('Done'),
  onError: (error) => print('Error: $error'),
)

Standalone Slider

Use BasicAudioSlider for custom player layouts:

BasicAudioSlider(
  value: currentPosition,
  max: totalDuration,
  onChanged: (value) { /* position changed */ },
  onChangeStart: () { /* seek started */ },
  onChangeEnd: () { /* seek ended */ },
  waveformData: waveformData,
  activeColor: Colors.blue,
  inactiveColor: Colors.grey,
  thumbShape: ThumbShape.verticalBar,
)

Global Theme

WavePlayerColors.theme = const WavePlayerTheme(
  primaryColor: Color(0xFF2196F3),
  successColor: Color(0xFF4CAF50),
  backgroundColor: Color(0xFFE3F2FD),
  surfaceColor: Color(0xFFFFFFFF),
  textColor: Color(0xFF1565C0),
  textSecondaryColor: Color(0xFF424242),
);

Example

cd example
flutter run

Requirements

  • Flutter 3.6+ / Dart 3.6+
  • iOS 11.0+ / Android API 21+

Dependencies

License

MIT โ€” see LICENSE.

Contributing

  1. Fork โ†’ Create branch โ†’ Commit โ†’ Push โ†’ Pull Request

Issues & questions: GitHub Issues

About

๐ŸŽต wave_player โ€” A Flutter widget for playing audio with a sleek waveform UI. Perfect for voice messages, chat bubbles, or any app that needs an interactive audio player with waveform visualization.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors