Comments (2)
Hey @mehyaz , Is it something like repeat song,
currently if you add songs to the playlist, and the playlist reaches the end of the list, by default it starts playing the list from the start, which is kind a like repeat all songs in the list.
You can take a look at JcAudioPlayer.java in line 114 the nextAudio() funtion you will see in line 126 : playAudio(playlist.get(0));
which means that if there is an exception like u reached something like the end of the list, it starts playing from the begining again.
If you want to work on this, here is a small suggestion you can start off with
Logic/Algorithm to get Working with the Repeat Funtion
- We will need a String field variable "repeatMode" in the JcAudioPlayer class which can be set to NONE/ALL/ONE by default it can be ALL. This varaible tells us whether we are Looping the Playlist or not.
- Have a button on the PlayerView layout XML with appropriate icons and assign them to the respective repeat button "repeatBtn" just like the play/prev/next button. and in the Listener repeatBtn.setOnClickListener - on Click of the button Check the current State of the repeatMode and change it accordingly. LOOK AT point 4.
- Now in the nextAudio() inside the JcAudioPlayer class checkout line 120: JcAudio nextJcAudio = playlist.get(currentPositionList + position);
before doing this do something like this
if(repeatMode.equals("NONE")||repeatMode.equals("ALL"))
{
JcAudio nextJcAudio = playlist.get(currentPositionList + position);
// this means as usual just play the next audio
}
else if(repeatMode.equals("ONE"))
{
JcAudio nextJcAudio = playlist.get(currentPositionList);
// this means repeat the audio
}
Now in the exception block
line 126: playAudio(playlist.get(0));
do this
if(repeatMode.equals("ALL"))
{
playAudio(playlist.get(0));
//repeat all the songs in the list
}
else
{
jcPlayerService.stop();
// don't repeat the list
}
//String currentRepeatMode="ALL"; declare this somewhere
4. You can create a public method setLooping(String mode) inside the JcAudioPlayer class and call it on the click of the repeat button
inside the handler for the repeatBtn onClickListener
if(currentRepeatMode.equals("ALL"))
{
currentRepeatMode="NONE";
setLooping(currentRepeatMode);
}
else if(currentRepeatMode.equals("NONE"))
{
currentRepeatMode="ONE";
setLooping(currentRepeatMode);
}
else
{
currentRepeatMode="ALL";
setLooping(currentRepeatMode);
}
DONE...HOPE THIS COULD GIVE EVERYONE AN IDEA ON WORKING WITH LOOPING AUDIO IN THE PLAYLIST>>
@jeancsanchez please take a look at this also..it might be helpful, Thank You.
from jcplayer.
Is there anyone to help?
from jcplayer.
Related Issues (20)
- How to get current time? HOT 3
- Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.5.0] AndroidManifest.xml:24:18-86 HOT 1
- Failed to resolve dependency HOT 2
- seek to specific position not working HOT 1
- Stopping & starting music on incoming calls HOT 1
- Slider and duration not synced to audio playing HOT 8
- Build was configured to prefer settings repositories over project repositories but repository 'BintrayJCenter' was added by build file 'build.gradle' HOT 1
- Android 12 API 31 : requires that one of FLAG HOT 2
- url playback is lost between 5 and 10 minutes
- E/MediaPlayerNative: error (1, -2147483648) HOT 2
- implementation 'com.github.jeancsanchez:JcPlayer:2.7.1' HOT 10
- (IlligalArgumentException) in jcNotificationPlayer.createNotificationPlayer. HOT 1
- Query on target sdk 31 support HOT 1
- Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE HOT 3
- InputDispatcher issue HOT 4
- Notification crashes App on Android 12 and above HOT 1
- Jcplayer doesn't identify the last song in the list
- dependency not imported in java project HOT 3
- Could not resolve com.github.jeancsanchez:JcPlayer:2.7.2 (may be similar to #139) HOT 5
- Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jcplayer.