audio_widget 0.0.1+3 copy "audio_widget: ^0.0.1+3" to clipboard
audio_widget: ^0.0.1+3 copied to clipboard

outdated

Play an audio on flutter can be as simple as display an image ! Just add a widget into the tree

audio_widget #

Audio.assets(
  path: "assets/audios/country.mp3",
  play: true, //AudioWidget does not maintain the play state
  child: ...
)

Update #

Like usual Flutter widgets, just update the parameters of the Audio

//inside a stateful widget

bool _play = false;

@override
Widget build(BuildContext context) {
  return Audio.assets(
     path: "assets/audios/country.mp3",
     play: _play,
     child: RaisedButton(
       child: Text(
         _play ? "pause" : "play",
       ),
       onPressed: () {
         setState(() {
           _play = !_play;
         });
       },
     ),
  );
}

Listeners #

Audio.assets(
  path: "assets/audios/country.mp3",
  play: _play,

  onReadyToPlay: (duration) {
     //onReadyToPlay
  },
  
  onPositionChanged: (current, duration) {
     //onReadyToPlay
  },

  child: ...
)

Player #

By default, Audio uses Assets Audio Player to play its songs

You can change it just by create a new wrapper of AudioWidgetPlayer

class AudioWidgetMyPlayer extends AudioWidgetPlayer {
  final MyPlayer _player = MyPlayer();

  @override
  void play() => _player.play();

  @override
  void pause() => _player.pause();

  //etc.

and update the defaultAudioWidgetPlayer inside your main

void main() {
    defaultAudioWidgetPlayer = () => AudioWidgetMyPlayer();
    runApp(MyApp());
}
10
likes
30
points
29
downloads

Publisher

unverified uploader

Weekly Downloads

Play an audio on flutter can be as simple as display an image ! Just add a widget into the tree

Repository (GitHub)

License

unknown (license)

Dependencies

assets_audio_player, flutter

More

Packages that depend on audio_widget