GithubHelp home page GithubHelp logo

moneycomposeaudioplayer's Introduction

Android仿支付宝金额语音播报

最近有个需求要优化金额到账音效,理了下实现思路: 1、根据数字转换金额 2、根据金额匹配音频文件 3、音频文件合成 4、按队列播放音频文件

解决方案: 想到支付宝实现的功能就不错,就反编译支付宝APK看看实现思路有没有更优的写法,除了第四条有点差别外基本都差不多。 第一二条:通过map预设好文字对应的音频文件,然后根据传入的金额匹配音频文件就好了。 第三条:音频合成之前没有处理过本以为会麻烦点,看过支付宝的写法只要使用合并流就可以了(前提是音频头一样)。 第四条:一开始的想法是用集合按顺序取出播放,后来因为合并音频流是比较耗时的操作需要交给线程池处理。 线程池可以通过newSingleThreadExecutor创建单线程池,线程池里任务的执行顺序是按照任务的提交顺序执行的, 所以只要控制线程池里线程的生命周期就可以按队列播放音频文件了。

写的Demo只是作为功能展示,如果需要在项目中使用还要替换掉支付宝的语音文件。

本文参考:https://github.com/eatdefecat/VoicePlay

moneycomposeaudioplayer's People

Contributors

tianyalu avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.