soundpool 0.0.3+3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new50

soundpool

A Flutter Sound Pool for playing short media files.

Inspired by Android SoundPool API.

0.0.1 (10-06-2018)

  • Initial release.
    • Loading sound files from assets.
    • Playing, stopping and pausing streams.
    • Releasing resources.
  • Works on Android and iOS.

0.0.3 (19-06-2018)

  • Load sound files from URI
  • Fix setVolume() and release() never finishing

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:soundpool/soundpool.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int dicesSoundId;

  int dicesStreamId;

  int dicesSoundFromUriId;

  double volume = 1.0;

  @override
  initState() {
    super.initState();
    initSoundPool();
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Soundpool plugin example app'),
        ),
        body: new Stack(
          children: <Widget>[
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                new Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 16.0),
                  child: new Text('Volume control'),
                ),
                new Slider(
                    value: volume,
                    onChanged: (newValue) {
                      setState(() {
                        volume = newValue;
                        updateVolume();
                      });
                    }),
              ],
            ),
            new Positioned(
                bottom: 16.0,
                left: 16.0,
                child: new FloatingActionButton(
                  onPressed:
                      dicesSoundFromUriId == null || dicesSoundFromUriId < 0
                          ? null
                          : () => playSoundFromUri(),
                  child: new Icon(Icons.play_arrow),
                ))
          ],
        ),
        floatingActionButton: new FloatingActionButton(
          onPressed: () => playSound(),
          child: new Icon(Icons.play_circle_filled),
        ),
      ),
    );
  }

  void initSoundPool() async {
    dicesSoundId =
        await rootBundle.load("sounds/dices.m4a").then((ByteData soundData) {
      return Soundpool.load(soundData);
    });
    await Soundpool.setVolume(soundId: dicesSoundId, volume: volume);
    dicesSoundFromUriId = await Soundpool.loadUri(
        "https://github.com/ukasz123/soundpool/raw/master/example/sounds/dices.m4a");
    print(
        "dicesSoundId = $dicesSoundId, dicesSoundFromUri = $dicesSoundFromUriId");
    setState(() {});
  }

  void playSound() async {
    if (dicesSoundId > -1) {
      dicesStreamId = await Soundpool.play(dicesSoundId, repeat: 4);
    }
  }

  void updateVolume() {
    if (dicesStreamId != null) {
      Soundpool.setVolume(
          streamId: dicesStreamId, soundId: dicesSoundId, volume: volume);
    } else {
      Soundpool.setVolume(soundId: dicesSoundId, volume: volume);
    }
  }

  void playSoundFromUri() {
    Soundpool.play(dicesSoundFromUriId);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  soundpool: "^0.0.3+3"

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:soundpool/soundpool.dart';
  
Version Uploaded Documentation Archive
0.0.3+3 Jun 19, 2018 Go to the documentation of soundpool 0.0.3+3 Download soundpool 0.0.3+3 archive
0.0.1+2 Jun 11, 2018 Go to the documentation of soundpool 0.0.1+2 Download soundpool 0.0.1+2 archive
0.0.1+1 Jun 10, 2018 Go to the documentation of soundpool 0.0.1+1 Download soundpool 0.0.1+1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
50
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.48.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7