GithubHelp home page GithubHelp logo

setLooping(true) ??? about jcplayer HOT 2 CLOSED

jeancsanchez avatar jeancsanchez commented on August 25, 2024
setLooping(true) ???

from jcplayer.

Comments (2)

peace-shillong avatar peace-shillong commented on August 25, 2024 3

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

  1. 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.
  2. 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.
  3. 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.

mehyaz avatar mehyaz commented on August 25, 2024

Is there anyone to help?

from jcplayer.

Related Issues (20)

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.