Giter Site home page Giter Site logo

recorderbutton's Introduction

###一个绚丽的录音按钮,带有水波纹效果,这是从真实项目里面挖下来的。 由于时间匆促,代码还有待重构。

###效果:

###使用方法:

  1. 在布局文件中添加

     <com.nan.recordbutton.widget.RecorderButton
             android:id="@+id/btn_record"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_centerInParent="true"
             android:layout_marginTop="10dp"
             android:background="@drawable/bg_record"
             app:bg_normal="@drawable/bg_record"
             app:bg_recording="@drawable/bg_recording"
             app:bg_want_cancel="@drawable/bg_record"
             app:max_record_time="15"
             app:max_voice_level="150"
             app:min_record_time="10"
             app:txt_normal=""
             app:txt_recording=""
             app:txt_want_cancel="" />
    
  2. 在Activity中找到RecorderButton以后记得设置监听器RecorderButton.AudioStateRecorderListener,从而实现自己的业务逻辑。具体可以参考项目中的代码。

     private RecorderButton btn_record;
     
     btn_record = (RecorderButton) findViewById(R.id.btn_record);
     btn_record.setAudioStateRecorderListener(new MyRecordListener());
    
     class MyRecordListener implements RecorderButton.AudioStateRecorderListener {
    
         @Override
         public void onStart(float time) {
         }
    
         @Override
         public void onUpdateTime(float currentTime, float minTime, float maxTime){
         }
    
         @Override
         public void onReturnToRecord() {   
         }
    
         @Override
         public void onWantToCancel() {	            
         }
    
         @Override
         public void onFinish(float seconds, String filePath) {
         }
    
         @Override
         public void onCancel(boolean isTooShort) {	
         }
    
         @Override
         public void onVoiceChange(int voiceLevel) {	
         }
     }
    

recorderbutton's People

Contributors

huannan avatar

Watchers

James Cloos 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.