zoukankan      html  css  js  c++  java
  • 声音

    https://stackoverflow.com/questions/43813386/how-to-play-a-custom-sound-in-flutter

    Thanks for checking out Flutter!

    Flutter SDK today (as of May 5, 2017) doesn't have built-in support to play and control arbitrary audio. However, we designed our plugin system to support it.

    This plugin adds audio support to Flutter: https://pub.dartlang.org/packages/audioplayer

    From the plugin's README:

    Future play() async {
      final result = await audioPlayer.play(kUrl);
      if (result == 1) setState(() => playerState = PlayerState.playing);
    }
    
    // add a isLocal parameter to play a local file
    Future playLocal() async {
      final result = await audioPlayer.play(kUrl);
      if (result == 1) setState(() => playerState = PlayerState.playing);
    }
    
    
    Future pause() async {
      final result = await audioPlayer.pause();
      if (result == 1) setState(() => playerState = PlayerState.paused);
    }
    
    Future stop() async {
      final result = await audioPlayer.stop();
      if (result == 1) {
        setState(() {
          playerState = PlayerState.stopped;
          position = new Duration();
        });
      }
    }
  • 相关阅读:
    POJ 1017
    poj 2709
    poj 1328
    POJ 2386
    POJ 1065
    POJ 3728
    hdu--1004--Let the Balloon Rise
    hdu--2570--迷瘴(贪心)
    hdu--1257--最少拦截系统(贪心)
    hdu--1230--火星A+B
  • 原文地址:https://www.cnblogs.com/pythonClub/p/10858694.html
Copyright © 2011-2022 走看看