An android music player ui library
To always build from the latest commit with all updates. Add the JitPack repository:
(path:\to\your\projects\MainFolderOfYourProject\build.gradle)
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Make minSdkVersion 14 and add the following dependency:
android{
...
defaultConfig{
...
minSdkVersion 14
...
}
}
dependencies {
implementation 'com.github.mergehez:ArgPlayer:v2.0'
}
<com.arges.sepan.argmusicplayer.PlayerViews.ArgPlayerSmallView
android:id="@+id/argmusicplayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.arges.sepan.argmusicplayer.PlayerViews.ArgPlayerLargeView
android:id="@+id/argmusicplayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.arges.sepan.argmusicplayer.PlayerViews.ArgPlayerFullScreenView
android:id="@+id/argmusicplayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
@Override
protected void onCreate(Bundle savedInstanceState) {
//... other codes ...
String url = "https://mergesoft.org/caruso.mp3";
ArgAudio audio = new ArgAudio("Bocelli","Caruso",url,AudioType.URL);
ArgPlayerSmallView argMusicPlayer = (ArgPlayerSmallView) findViewById(R.id.argmusicplayer);
argMusicPlayer.play(audio);
//... other codes ...
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//... other codes ...
ArgAudio audio1 = new ArgAudio("Singer1","Audio1",url,AudioType.URL);
//Define audio2, audio3, audio4 ......
ArgAudioList playlist = new ArgAudioList(true).add(audio1)
.add(audio2)
.add(audio3)
.add(audio4);
ArgPlayerSmallView argMusicPlayer = (ArgPlayerSmallView) findViewById(R.id.argmusicplayer);
argMusicPlayer.playPlaylist(playlist );
//... other codes ...
}
Return | Method/Description |
---|---|
void | play(ArgAudio audio) Directly play an audio |
void | playPlaylist(ArgAudioList list) Directly play a playlist |
void | loadSingleAudio(ArgAudio audio) Load an audio to play later |
void | playLoadedSingleAudio() Play the loaded audio if exists |
void | loadPlaylist(ArgAudioList list) Load a playlist to play later |
void | playLoadedPlaylist() Play the loaded playlist if exists |
void | pause() Pause a playing audio |
void | resume() Resume the playing audio |
void | stop() Stop audio |
boolean | seekTo(int millisec) Seek audio to milliSec return: if seeking position is greater than duration or less than 0, it returns false |
boolean | forward(int milliSec, boolean willPlay) Forward audio as long as milliSec willPlay: if audio will play after forwarding, set this truereturn: If forwarding position is greater than duration, it returns false |
boolean | backward(int milliSec, boolean willPlay) Backward audio as long as milliSec willPlay: if audio will play after backwarding, set this truereturn: If backwarding position is less than 0, it returns false |
ArgAudio | getCurrentAudio() Get the current audio if available |
long | getDuration() Get duration of current audio |
boolean | isPlaying() Check if an audio is playing |
boolean | isPaused() Check if an audio is paused |
void | playAudioAfterPercent(int percent) Audio will plays after % percent buffered. Only when audio type is Url. Default percent is %50. |
void | enableProgress() and disableProgress() Enable/Disable Progress View. Defaultly is enabled |
void | setProgressMessage(String message) Change Progress View message. Default message is 'Audio is Loading..' |
void | enableErrorView() and disableErrorView() Enable/Disable Error View. Error view appears when an error has occured. Defaultly is enabled |
void | enableNextPrevButtons() and disableNextPrevButtons() Use can disable next/previous playback control but Defaultly is enabled |
void | enableNotification(Class activityClass) Enable notification. With this option users will be able to control music player on notification panel. Look at screenshots.. |
void | enableNotification(Class homeClass, int notifImgResId) Enable notification. With this option users will be able to control music player on notification panel. Look at screenshots.. homeClass: When click on notification home will open.notifImgResId: Resource id for ImageView on the notification layout. |
void | disableNotification() Disable notification option. If notification was enabled before, it will be cancelled. Notification defaultly is disabled |
void | continuePlaylistWhenError() If an error occures, player won't publish error and will play next audio. |
void | stopPlaylistWhenError() If an error occures, player will stop playing and publish error. Defaultly player publishes errors. |
void | setPlaylistRepeat(boolean repeat) Set repetition of the playlist. Default value is true |
void | setAllButtonsImageResource(int resIdPlay,int resIdPause,int resIdPrev,int resIdNext,int resIdRepeat,int resIdNotRepeat) You can change image resources of all control buttons by this method. |
void | setPrevButtonImageResource(int resId) Change only image resource of the previous control button |
void | setNextButtonImageResource(int resId) Change only image resource of the next control button |
void | setPlayButtonImageResource(int resId) Change only image resource of the play control button |
void | setPauseButtonImageResource(int resId) Change only image resource of the pause control button |
void | setRepeatButtonImageResource(int repeatResId, int notRepeatResId) Change only image resource of the repeat control button. repeatResId : when repeatition is enabled notRepeatResId : when repeatition is disabled |
void | setOnErrorListener(Arg.OnErrorListener onErrorListener) setOnPreparedListener(Arg.OnPreparedListener onPreparedListener) setOnPausedListener(Arg.OnPausedListener onPausedListener) setOnPlayingListener(Arg.OnPlayingListener onPlayingListener) setOnCompletedListener(Arg.OnCompletedListener onCompletedListener) setOnTimeChangeListener(Arg.OnTimeChangeListener onTimeChangeListener) setOnPlaylistAudioChangedListener(Arg.OnPlaylistAudioChangedListener onPlaylistAudioChangedListener) Set listeners to handle broadcasts |
Return | Method/Description |
---|---|
ArgAudio | static createFromRaw(@RawRes int rawId) Short way to create an audio from raw resources. Singer an audio name will be defined as rawId. |
ArgAudio | static createFromRaw(String singer, String audioName, @RawRes int rawId) Create a raw type audio. |
ArgAudio | static createFromAssets(String assetName) Short way to create an audio from raw resources. Singer an audio name will be defined as assetName. |
ArgAudio | static createFromAssets(String singer, String audioName, String assetName) Create an assets type audio. |
ArgAudio | static createFromURL(String url) Short way to create an audio from raw resources. Singer an audio name will be defined as url. |
ArgAudio | static createFromURL(String singer, String audioName, String url) Create an url type audio. |
ArgAudio | static createFromFilePath(String filePath) Create a filepath type audio. |
ArgAudio | static createFromFilePath(String singer, String audioName, String filePath) Short way to create an audio from raw resources. Singer an audio name will be defined as filePath. |
ArgAudio | cloneAudio() Clone the audio. |
ArgAudio | makePlaylist() Make audio as a playlist audio. |
boolean | isPlaylist() Check if the audio is a playlist audio. |
Return | Method/Description |
---|---|
ArgAudioList | add(@NonNull ArgAudio audio) Add an ArgAudio |
ArgAudio | getCurrentAudio() Get current(playing) audio. |
int | getCurrentIndex() Get index of current audio. |
boolean | equals(Object obj) Check if another ArgAudioList object is equals current one. Method checks emptyness, equalness of first and last childs of objects and sizes. |
void | goTo(int index) Change playing audio of playlist. |
boolean | hasNext() Check if any next audio |
int | getNextIndex() Get index of next audio. |
boolean | goToNext() Set next audio as playing audio. If this action is not possible, method returns false. |
boolean | hasPrev() Check if any previous audio |
int | getPrevIndex() Get index of previous audio. |
boolean | goToPrev() Set previous audio as playing audio. If this action is not possible, method returns false. |