Git Product home page Git Product logo

argplayer's Introduction

ArgPlayer

An android music player ui library

Builds:

Table of Contents

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

<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://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

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

Error View

Notification

Small Player View

Large Player View

Fullscreen Player View

argplayer's People

Contributors

mazlumozdogan avatar mergehez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

argplayer's Issues

Skip-Forward button after loadPlaylist() throws an error

If I use .loadPlaylist() without calling .playLoadedPlaylist() right after, ArgPlayer throws an Exception upon (manually) pressing the Play-button and skipping to the next track:

image

You can check out the complete code in my most recent commit on Composition Compass:

SHA-1: 03f81fac44ca5cc52a1af263a9be257e958405c0

* Player WIP; still broken due to usage of loadPlaylist instead of playLoadedPlaylist

IMO .playLoadedPlaylist() should not be required, and only be used if you want to programmatically start a playback of the playlist. That's why I see this behavior as a bug.

Only play video Once second time I got error

Hello dear,

I am using this player in my project and I am facing weird problem, the problem is player is playing from file path first time and second time it is not play it is giving error.

Regards,

underrated

this looks incredible, why isn't this popular? o.o

enableNotification()

Hello,. Thanks alot for this library it works well. The only problem is the enableNotification method. Its not working. The audio plays but the notification isnt showing. Kindly help, thank you

Android resource linking failed

as per the documentation library successfully implemented.

After on build got

Android resource linking failed
AAPT: error: resource android:style/android:Widget.ImageButton not found.
error: failed linking references.

I am using material theme is there any issue with it
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

Next Previous Button don't work

When player a playlist next and previous buttons do nothing,

ArgAudio audio1 = new ArgAudio("Led Zepplin", "Immigrant Song", this.getString(R.string.song1), AudioType.URL); ArgAudio audio2 = new ArgAudio("Linkin Park", "In the End", this.getString(R.string.song2), AudioType.URL); ArgAudio audio3 = new ArgAudio("One Direction", "Best Song Ever", this.getString(R.string.song3), AudioType.URL); playlist = new ArgAudioList(true).add(audio1) .add(audio2) .add(audio3); argMusicPlayer = findViewById(R.id.musicplayer); argMusicPlayer.enableNotification(MainActivity.class); argMusicPlayer.playPlaylist(playlist);

raw no longer exists

int res1 = R.raw.nausicaa_requiem; and all related (raw button, add(rawAudio) and so on) should be removed, or R.raw.nausicaa_requiem.mp3 should be re-added to maintain buildability

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.