Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter button sound effects

import 'package:soundpool/soundpool.dart';
import 'package:get/get.dart';

class PcmController extends GetxController {
  Soundpool _pool;
  int idMicUp;
  SoundpoolOptions _soundpoolOptions =
      SoundpoolOptions(streamType: StreamType.notification);


  @override
  void onInit() {
    _pool = Soundpool.fromOptions(options: _soundpoolOptions);
    _loadSounds();
    super.onInit();
  }

  _loadSounds() async {
    var asset = await rootBundle.load("assets/sounds/micUp.m4a");
    idMicUp = await _pool.load(asset);
  }

  playSound() async {
    await _pool.play(idMicUp);
  }
}
Source by pub.dev #
 
PREVIOUS NEXT
Tagged: #flutter #button #sound #effects
ADD COMMENT
Topic
Name
5+7 =