Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mergehez/argplayer

An android music player library
https://github.com/mergehez/argplayer

android android-music-player library music-player music-player-ui player ui

Last synced: 2 months ago
JSON representation

An android music player library

Awesome Lists containing this project

README

        

# ArgPlayer
An android music player ui library

Builds: [![](https://jitpack.io/v/mergehez/ArgPlayer.svg)](https://jitpack.io/#mergehez/ArgPlayer)

## Table of Contents
* [Installation](#installation)
* [How to Use](#how-to-use)
* [XML Codes](#xml-codes)
* [Small View](#for-small-view)
* [Large View](#for-large-view)
* [Full Screen View](#for-full-screen-view)
* [Simplest Usage](#simplest-usage)
* [Play Simple Audio](#play-simple-audio)
* [Play Playlist](#play-playlist)
* [Player Methods](#player-methods)
* [ArgAudio Methods](#argaudio)
* [ArgAudioList Methods](#argaudiolist)
* [ArgNotificationOptions Methods](#argnotificationoptions)
* [ScreenShots](#screenshots)

## Installation
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" }
}
}
```
Set minSdkVersion to 21 and add the following dependency:

```
android{
...
defaultConfig{
...
minSdkVersion 21
...
}
}
dependencies {
implementation 'com.github.mergehez:ArgPlayer:v3.1'
}
```

> Note: You may encounter the error below. See this stackoverflow question: [link](https://stackoverflow.com/questions/69163511/build-was-configured-to-prefer-settings-repositories-over-project-repositories-b)

> `Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'`

## How to use

### XML Codes
#### for small view:
```xml

```
#### for large view:
```xml

```
#### for full screen view:
```xml

```

----
### Simplest Usage
#### Play Simple Audio
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
//... other codes ...
String url = "https://www.gotinenstranan.com/songs/joan-baez-north-country-blues.mp3";
ArgAudio audio = ArgAudio.createFromURL("Joan Baez", "North Country Blues", url);

ArgPlayerSmallView argMusicPlayer = (ArgPlayerSmallView) findViewById(R.id.argmusicplayer);
argMusicPlayer.play(audio);
//... other codes ...
}
```
#### Play Playlist

```java
@Override
protected void onCreate(Bundle savedInstanceState) {
//... other codes ...
ArgAudio audio1 = ArgAudio.createFromURL("Joan Baez", "North Country Blues", url1)
//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 plays an audio|
| void |`playPlaylist(ArgAudioList list)`
Directly plays a playlist|
| void |`loadSingleAudio(ArgAudio audio)`
Loads an audio to play later|
| void |`playLoadedSingleAudio()`
Plays the loaded audio if exists|
| void |`loadPlaylist(ArgAudioList list)`
Loads a playlist to play later|
| void |`playLoadedPlaylist()`
Plays the loaded playlist if exists|
| void |`pause()`
Pauses a playing audio|
| void |`resume()`
Resumes the playing audio|
| void |`stop()`
Stops audio|
| boolean |`seekTo(int millisec)`
Seeks 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()`
Gets the current audio if available|
| long|`getDuration()`
Gets duration of current audio|
| boolean|`isPlaying()`
Checks if an audio is playing|
| boolean|`isPaused()`
Checks if an audio is paused|
| void |`playAudioAfterPercent(int percent)`
Audio plays as soon as %`percent` is buffered. Only when audio type is Url. *Default percent is **%50**.* |
| void |`enableProgress()` and `disableProgress()`
Enable/Disable Progress View. *As default is **enabled***|
| void |`setProgressMessage(String message)`
Change Progress View message. *Default message is **'Audio is Loading..'***|
| void |`enableErrorView()` and `disableErrorView()`
Enables/Disables Error View. Error view appears when an error occurs. *Default value is **enabled*** |
| void |`enableNextPrevButtons()`and `disableNextPrevButtons()`
Enables/disables next/previous playback control. *Default behavior is **enabled***|
| void |`enableNotification(Activity activity)`
Enables notification. Look at screenshots..
*`activity:`* Current activity (You'd probably pass **this** keyword). |
| void |`enableNotification(ArgNotificationOptions options)`
Enables notification with custom options such as image, channel name etc.
*`options:`* An ArgNotificationOptions instance. |
| void |`disableNotification()`
Disable notification option. If notification was enabled before, it will be cancelled. *Default value for Notification 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. *As default **player publishes errors***.|
| void |`setPlaylistRepeat(boolean repeat)`
Sets 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)`
Sets image resource of the *previous* control button|
| void |`setNextButtonImageResource(int resId)`
Changes image resource of the *next* control button|
| void |`setPlayButtonImageResource(int resId)`
Sets image resource of the *play* control button|
| void |`setPauseButtonImageResource(int resId)`
Sets image resource of the *pause* control button|
| void |`setRepeatButtonImageResource(int repeatResId, int notRepeatResId)`
Sets image resource of the *repeat* control button.
*`repeatResId`*: when repetition is enabled
*`notRepeatResId`*: when repetition 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)`
Sets listeners to handle broadcasts|


#### ArgAudio
| Return | Method/Description |
| :-- |:--|
| ArgAudio |*`static`*`createFromRaw(@RawRes int rawId)`
Short way to create an audio from raw resources. Singer and audio name will be set to *rawId*.|
| ArgAudio |*`static`*`createFromRaw(String singer, String audioName, @RawRes int rawId)`
Creates a raw type audio.|
| ArgAudio|*`static`*`createFromAssets(String assetName)`
Short way to create an audio from raw resources. Singer and audio name will be set to *assetName*.|
| ArgAudio|*`static`*`createFromAssets(String singer, String audioName, String assetName)`
Creates an assets type audio.|
| ArgAudio|*`static`*`createFromURL(String url)`
Short way to create an audio from raw resources. Singer and audio name will be set to *url*.|
| ArgAudio|*`static`*`createFromURL(String singer, String audioName, String url)`
Creates an url type audio.|
| ArgAudio|*`static`*`createFromFilePath(String filePath)`
Creates a filepath type audio.|
| ArgAudio|*`static`*`createFromFilePath(String singer, String audioName, String filePath)`
Short way to create an audio from raw resources. Singer and audio name will be set to *filePath*.|
| ArgAudio|`cloneAudio()`
Clones the audio.|
| ArgAudio|`convertToPlaylist()`
Makes audio as a playlist audio.|
| boolean|`isPlaylist()`
Checks if the audio is a playlist audio.|


#### ArgAudioList
| Return | Method/Description |
| :-- |:--|
| ArgAudioList|`add(@NonNull ArgAudio audio)`
Add an ArgAudio|
| ArgAudio |`getCurrentAudio()`
Gets current(playing) audio.|
| int|`getCurrentIndex()`
Gets index of current audio.|
| boolean|`equals(Object obj)`
Checks if another ArgAudioList object is equal to the current one. Checks emptyness, equalness of first and last childs of objects and sizes. |
| void |`goTo(int index)`
Changes playing audio of playlist.|
| boolean|`hasNext()`
Checks if any next audio|
| int|`getNextIndex()`
Gets index of next audio.|
| boolean|`goToNext()`
Sets next audio as playing audio. If this action is not possible, method returns false.|
| boolean|`hasPrev()`
Checks if any previous audio|
| int|`getPrevIndex()`
Gets index of previous audio.|
| boolean|`goToPrev()`
Sets previous audio as playing audio. If this action is not possible, method returns false.|


#### ArgNotificationOptions
| Return | Method/Description |
| :-- |:--|
| OnBuildNotificationListener |`getListener()`
Gets the listener.|
| ArgNotificationOptions |`setListener()`
Sets the listener.|
| bool|`isProgressEnabled()`
Checks whether progress is enabled. |
| ArgNotificationOptions|`setProgressEnabled(boolean progressEnabled)`
Checks whether progress is enabled. (Current time and a progress view is visible if set to true)|
| int |`getNotificationId()`
Gets notification id. |
| ArgNotificationOptions |`setNotificationId(int notificationId)`
Sets notification id.|
| String |`getChannelId()`
Gets channel id.
Requires MinSDK of 26 (O)|
| ArgNotificationOptions |`setChannelId(CharSequence channelId)`
Sets channel id.
Requires MinSDK of 26 (O)|
| String |`getChannelName()`
Gets channel name.
Requires MinSDK of 26 (O)|
| ArgNotificationOptions |`setChannelName(CharSequence channelName)`
Sets channel name.
Requires MinSDK of 26 (O)|


## ScreenShots
### Progress View
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/progressx.png "")
---
### Error View
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/errorviewx.png "")
---
### Notification
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/notification-with-progress.png "")
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/notification-without-progress.png "")
---
### Small Player View
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/smallview.png "")

### Large Player View
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/largeview.png "")
---
### Fullscreen Player View
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/fullscreenview.png "")
![](https://raw.githubusercontent.com/mergehez/ArgPlayer/master/ScreenShots/fullscreenview-playlist.png "")