Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 578 Bytes

useAudio.md

File metadata and controls

31 lines (25 loc) · 578 Bytes

useAudio

Creates AudioPlayer, tracks its state and exposes playback controls.

Installation

Depends on just_audio.

dependencies:
  flutter_use_audio: ^0.0.2

Usage

class Sample extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final player = useAudio();
    return ElevatedButton(
      onPressed: () async {
        player.play();
        await player.seek(const Duration(seconds: 10));
        await player.pause();
      },
      child: const Text('Play'),
    );
  }
}