tolgatasci / ArgPlayer

An android music player library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArgPlayer

An android music player ui library

Builds:

Table of Contents

Gradle

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.1'
}

How to use

XML Codes

for small view:

<com.arges.sepan.argmusicplayer.PlayerViews.ArgPlayerSmallView
	android:id="@+id/argmusicplayer"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"/>

for large view:

<com.arges.sepan.argmusicplayer.PlayerViews.ArgPlayerLargeView
	android:id="@+id/argmusicplayer"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"/>

for full screen view:

<com.arges.sepan.argmusicplayer.PlayerViews.ArgPlayerFullScreenView
	android:id="@+id/argmusicplayer"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"/>

Simplest Usage

Play Simple Audio

@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 ...
}

Play Playlist

@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 ...
}

Player Methods

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 true
return: 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 true
return: 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

ArgAudio

Return Method/Description
ArgAudio staticcreateFromRaw(@RawRes int rawId)
Short way to create an audio from raw resources. Singer an audio name will be defined as rawId.
ArgAudio staticcreateFromRaw(String singer, String audioName, @RawRes int rawId)
Create a raw type audio.
ArgAudio staticcreateFromAssets(String assetName)
Short way to create an audio from raw resources. Singer an audio name will be defined as assetName.
ArgAudio staticcreateFromAssets(String singer, String audioName, String assetName)
Create an assets type audio.
ArgAudio staticcreateFromURL(String url)
Short way to create an audio from raw resources. Singer an audio name will be defined as url.
ArgAudio staticcreateFromURL(String singer, String audioName, String url)
Create an url type audio.
ArgAudio staticcreateFromFilePath(String filePath)
Create a filepath type audio.
ArgAudio staticcreateFromFilePath(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.

ArgAudioList

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.

ScreenShots

Progress View

Error View

Notification

Small Player View

Player Views ScreenShots

About

An android music player library

License:Apache License 2.0


Languages

Language:Java 100.0%