Resonance

Resonance 是 Flutter 音量控制和震动插件

特点

  • 获取当前音量级别
  • 获取最大音量级别
  • 设置音量级别
  • 设置最大音量级别
  • 设置静音级别
  • 显示音量UI(仅限Android)
  • 音量流类型(音乐、通知、闹钟等)
  • 可监听的音量级别

用法

获取当前音量级别

/// [streamType] by the default is set to [StreamType.music]
var crntVol = await Resonance.getCurrentVolumeLevel(streamType: StreamType.alarm);
print(crntVol);

设置音量级别

/// [showVolumeUI] by the default is set to false
var crntVol = await Resonance.setVolumeLevel(0.5, showVolumeUI: true);
print(crntVol);

监听器

@override
void initState() {
    super.initState();
    /// Add listener
    Resonance().addListener((volume) {
        setState(() {
            _volumeLevel = volume;
        });
    });
}

@override
void dispose() {
    /// Don't forget to use [removeListener] after
    Resonance().removeListener();
    super.dispose();
}

状态

版本 0.0.1 发布

笔记

目前,该插件仅适用于 Android。
欢迎提交 Pull Request 和贡献。

开发者

Tegar Bangun Suganda

@canaryv8 (Twitter)
@suganda8 (Github)

许可证

MIT License

Copyright (c) 2022 Tegar Bangun Suganda (ASTARIA)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

GitHub

查看 Github