- Notifications
You must be signed in to change notification settings - Fork77
A simple themable & integrable audio player library for Android.
License
jaydeepw/audio-wife
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A simple themable & integrable audio player library for Android. Helps you have an Audio Controllerfor your Audio Player UI. Have your own UI and pass the instance of UI controls likePlay button, Pause button, Seekbar etc to AudioWife and rest is taken care of.
your_player.xml
Eclipse library project structure has been dropped. If you wish to use this library in your eclipse IDE, please checkouteclipse-develop.No further development will be done or merged intoeclipse-develop branch.
- A simple native audio player API wrapper
- Others found were complex & provided no way to be integrate as library
- Some even involved compilation using Android NDK
- Provides default UI truly making it an integrable player.
- Ability to set multiple custom click handlers to play and pause buttons.
- No dependencies.
AudioWife is presented as anAndroid library project.
You can include this project byreferencing it as a library project inEclipse or ant.
This project has NO DEPENDENCIES.
Gradle:
{compile'net.the4thdimension:audio-wife:1.0.3'}
Requires Android 4.0+.
Permission required to play audio
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" />
##Using default player UI
AudioWife comes with a simple default player UI that you can use right away.This is the simplest and fastest way to get AudioWife working.
// mPlayerContainer = Parent view to add default player UI to.AudioWife.getInstance().init(mContext,uri).useDefaultUi(mPlayerContainer,getLayoutInflater());
##Using custom player UI
You can initialize the custom player controls of your UI using AudioWife
// initialize the player controlsmPlayMedia =findViewById(R.id.play);mPauseMedia =findViewById(R.id.pause);mMediaSeekBar = (SeekBar)findViewById(R.id.media_seekbar);mRunTime = (TextView)findViewById(R.id.run_time);mTotalTime = (TextView)findViewById(R.id.total_time);// AudioWife takes care of click handler for play/pause buttonAudioWife.getInstance() .init(mContext,uri) .setPlayView(mPlayMedia) .setPauseView(mPauseMedia) .setSeekBar(mMediaSeekBar) .setRuntimeView(mRunTime) .setTotalTimeView(mTotalTime);// to explicitly pauseAudioWife.getInstance().pause();// when done playing, release the resourcesAudioWife.getInstance().release();
##Add custom listeners
To extend the capabilities of AudioWife, custom click listeners can be attached.Refer to source documentation for more details.
AudioWife.getInstance().addOnCompletionListener(newMediaPlayer.OnCompletionListener() {@OverridepublicvoidonCompletion(MediaPlayermp) {Toast.makeText(getBaseContext(),"Completed",Toast.LENGTH_SHORT) .show();// do you stuff}});AudioWife.getInstance().addOnPlayClickListener(newView.OnClickListener() {@OverridepublicvoidonClick(Viewv) {Toast.makeText(getBaseContext(),"Play",Toast.LENGTH_SHORT) .show();// Lights-Camera-Action. Lets dance.}});AudioWife.getInstance().addOnPauseClickListener(newView.OnClickListener() {@OverridepublicvoidonClick(Viewv) {Toast.makeText(getBaseContext(),"Pause",Toast.LENGTH_SHORT) .show();// Your on audio pause stuff.}});
This relates with another Android AudioRecorder library project that is coming soon.The name AudioWife comes from an analogy of a married couple where the wife is an active Player, hence AudioWifefor Audio Player and husband being a Listener hence AudioHusband for Audio Recorder.
Later found that Audio Recorder Library project already exists for Android.You can find ithere.
Please fork this repository and contribute back usingpull requests.
Please follow Android codingstyle guide
- Jaydeep Wagh -jaydeep.w@gmail.com
- Twitter -Jaydeep_W
Official Android MediaPlayer Dev Docs
The MIT License (MIT)Copyright (c) 2014 JaydeepPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.
About
A simple themable & integrable audio player library for Android.