minisound 1.1.4 copy "minisound: ^1.1.4" to clipboard
minisound: ^1.1.4 copied to clipboard

A high-level real-time audio playback library based on Miniaudio.

example/lib/main.dart

import "package:flutter/material.dart";
import "package:minisound/minisound.dart";

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const MaterialApp(
    title: "Minisound Example",
    home: ExamplePage(),
  ));
}

class ExamplePage extends StatefulWidget {
  const ExamplePage({super.key});

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  final engine = Engine();

  late final Future<Sound> soundFuture = () async {
    await engine.init();
    return engine.loadSoundAsset("assets/laser_shoot.wav");
  }();

  @override
  Widget build(BuildContext context) => Scaffold(
        body: Center(
          child: FutureBuilder(
            future: soundFuture,
            builder: (context, snapshot) =>
                snapshot.connectionState == ConnectionState.done &&
                        snapshot.hasData
                    ? ElevatedButton(
                        child: const Text("LASER SHOOT"),
                        onPressed: () async {
                          await engine.start();

                          final sound = snapshot.data!;
                          sound.play();
                        },
                      )
                    : const CircularProgressIndicator(),
          ),
        ),
      );
}
9
likes
0
pub points
67%
popularity

Publisher

unverified uploader

A high-level real-time audio playback library based on Miniaudio.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, minisound_ffi, minisound_platform_interface, minisound_web

More

Packages that depend on minisound