Skip to content

javaexception/VoiceAnnouncements

Repository files navigation

VoiceAnnouncements

Android实现收款成功金额的语音播报功能(Nice tone)

a1.jpg

Gradle依赖 -

1.最app外层的build.gradle 添加代码:

allprojects {
    repositories {
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

2.在app 的build.gradle中添加:

	dependencies {
     compile 'com.github.javaexception:VoiceAnnouncements:v1.2'
	}

使用方法 -

1.普通调用

```
VoiceUtils.with(this).Play("1111",true);
```

   2.防止用户同时接收多条语音造成的语音重叠,采用下面的调用方法:

  ```
   private synchronized  void Play(final String str) {

                if (VoiceUtils.with(this).GetIsPlay()){
                    System.out.println("正在播放语音 ");
                    new Thread() {
                        @Override
                        public  void run() {
                            super.run();
                            try {
                                Thread.sleep(100);//休眠0.1秒
                                Play(str);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }.start();
                }else {
                    VoiceUtils.with(this).Play(str,true);
                }
            }
  ```

  如果是true播报语音为"收款成功+收款金额",如果是false只播报收款金额.

播报语速的调控问题,现在因为只能支持Android6.0以上的,所以代码我没添加,等解决后一起更新.

简书地址

我的公众号如下:

安卓干货铺

a2.jpg

About

Android实现收款成功金额的语音播报功能(Nice tone)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages