flutter_ogg_piano 1.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

flutter_ogg_piano #

Put sound and adjust pitching with Android internal codes in Flutter

Getting Started #

Implementation #

To implement this plugin in Flutter, add this line in dependencies section in pubspec.yaml

flutter_ogg_piano : ^1.0.4

Example #

Before you using this FlutterOggPiano class, you always have to call init method first. There is maximum number of sounds which can be played for Android, default is 128 and you can change this value Be aware that this plugin can't hold sound longer than 5 seconds duration.

FlutterOggPiano fop = FlutterOggPiano();

//In somewhere of codes...
fop.init();
//With maximum number of sounds
fop.init(max: 64);

This example shows how you use FlutterOggPiano with sounds file saved in assets folder. In pubspec.yaml file...

assets:
  - assets/123.ogg
  - assets/456.ogg

When you load file, app will generate temporary sound file into device and won't be removed for usage later. To replace this file, you have to set replace parameter to true, or it will load old data. You can load sound file like this,

//In somewhere of codes
rootBundle.load("assets/123.ogg").then((ogg) {
  //If you want to overload already existing sounds...
  fop.load(src: ogg, name: "123.ogg", index: 1, forceLoad: true);
  //If you want to load it normally...
  fop.load(src: ogg, name: "123.ogg", index: 1);
  //If you want to replace generated temp file...
  fop.load(src: ogg, name: "123.ogg", index: 1, forceLoad: true, replace: true);
});

rootBundle.load("assets/456.ogg").then((ogg) {
  fop.load(src: ogg, index: 0);
});

//Keep going for more sounds

When you make it play sound, you have to put note value. 1 value difference is 1 semitone difference. Negative value for lower pitch and positive value for higher pitch. Zero for same pitch with source sound.

//Somewhere of codes...
fop.play(index: 1, note: -1) // 1 lower semitone with 123.ogg sound
fop.play(index: 0, note: 3) //3 higher semitones with 456.ogg sound

Don't forget to release it after using this class

fop.release();

It will automatically prevent playing/loading sound with released state, but you can simply check if it's released by calling this

fop.isReleased().then((r) {
  //Do something
})

1.0.4 #

  • Fixed awaiting stuck problem

1.0.3 #

  • Added temp replacing feature

1.0.2 #

  • Matched methods

1.0.1 #

  • Fix small bug

1.0.0 #

  • First release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_ogg_piano/flutter_ogg_piano.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await FlutterOggPiano.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Running on: $_platformVersion\n'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_ogg_piano: ^1.0.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


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

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Android

Because:

  • package:flutter_ogg_piano/flutter_ogg_piano.dart that imports:
  • package:flutter_ogg_piano/tempFileExporter.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform Linux

Because:

  • package:flutter_ogg_piano/flutter_ogg_piano.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:flutter_ogg_piano/flutter_ogg_piano.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:flutter_ogg_piano/flutter_ogg_piano.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform iOS

Because:

  • package:flutter_ogg_piano/flutter_ogg_piano.dart that imports:
  • package:flutter_ogg_piano/tempFileExporter.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform macOS

Because:

  • package:flutter_ogg_piano/flutter_ogg_piano.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • flutter_ogg_piano that is a package requiring null.

Health suggestions

Format lib/flutter_ogg_piano.dart.

Run flutter format to format lib/flutter_ogg_piano.dart.

Format lib/tempFileExporter.dart.

Run flutter format to format lib/tempFileExporter.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
path_provider ^1.6.9 1.6.11
Transitive dependencies
collection 1.14.12 1.14.13
file 5.2.1
intl 0.16.1
meta 1.1.8 1.2.2
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
flutter_test