Creates AudioPlayer
, tracks its state and exposes playback controls.
Depends on just_audio.
dependencies:
flutter_use_audio: ^0.0.2
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'),
);
}
}