Sound player compactible with processing 3.x

edited April 2016 in Android Mode

I was using apwidget music player but it doesnt work anymore..Any sugestions?

Tagged:

Answers

  • Did you try the cassette library? it works for me, Processing 3.0.2 and Android mode 3.0RC3

    Kf

  • Hello,

    I'm trying to use cassette library it works for me too but I don't manage to play again a sound I have stoped with Track0.stop(); (Track0 is an instance of the soundplayer) kfrajer, do you have a small piece of code to share to see where / why it's not working as expected for me ?

    thanks benjamin

  • public void mousePressed() { 
      if(isPlaying){
        music.stop();
        isPlaying=false;
    
      }
      else{    
        music = new SoundFile(this,"Crickets.mp3");
        //EITHER option if you want continuous playing or single play
        //music.play();
        music.loop();
        isPlaying=true;
      }
    
    } 
    

    I start by setting up my bool variable "isPlaying" as false in my setup() method. This is the way I was able to get it to work. I didn't look into the documentation of the library too deep but I will take a guess at saying that when you stop the player it will call its destructor function. I also think that the pause and onResume methods were overriden and set to do nothing. You might be able to see that yourself if you look up the code in github. Last, I am not sure if you can adjust the volume of the object in the setup method. I think one needs to extend objects from other libraries. I might look into this extra feature in the future. I hope this helps,

    Kf

  • Yes, thanks, it helped a lot I now manage to play and stop a sound as my players are in a draw loop, I use case 0, case 1 to call the player just once but when I switch from one sound to another, I have a stange behavior, as if the player whas launched on each loop.

    void joueAudio0(){
        switch(isPlaying){
          //########################
          case 0:
            Track0 = new SoundFile(this, "0.wav");
            Track0.play();
            isPlaying = 1;
            break;
          //########################
          case 1:
            text(str(frameRate), displayWidth-100, 40);
            break;
          //########################
        }
    }
    void stopAudio0(){
            Track0.stop();
            isPlaying = 0;
        }
    

    and I iterate this function joueAudio1(); stopAudio(1); ... as I didn't manage to find the way to implement the Track as tried below

    void stopAudio(int page){
            numfichaudio = page + ".wav";
            Track="Track" + page;
            Track.stop();
            isPlaying = 0;
        }
    

    btw, what markdown do you use to publish code with nice lines ?

    best++ b

  • b01b01
    edited April 2016

    yes, thks GoToLoop in fact it was the preview that make me tought the markdown was not the good one ++ b

  • now it works : well in fact, I had to release the player so as to be able to reload it, and put it in a case so as to be played only once in the draw loop

    void drawScreen1() {
        background(255);
        switch(isPlaying){
          //########################
          case 1:
            Track1 = soundLoad("1.wav");
            soundPlay(Track1);
            isPlaying = 2;
            break;
          //########################
          case 2:
          if (soundIsPlaying(Track1) == true){
            tournePlay(degrr);
            degrr = degrr + 10;
            if (degrr==360) {degrr=0;}}
          else  {        
            cp5.getGroup("repl").show();
            };
            break;
         }
        }
    

    To realease it (in my case the stop and release what linked to a controlP5 event)

    {Track1.stop(); Track1.release();}
    

    the code of the whole project is here https://github.com/b01xy/quizzdesignaudio

    ++ b

Sign In or Register to comment.