Pàgines

Oct 7, 2011

Ringtone with Android-Processing

If you want to get a ring tone here you have the code:

//http://developer.android.com/reference/android/media/RingtoneManager.html

import android.media.Ringtone;
import android.media.RingtoneManager;
import android.database.Cursor;

RingtoneManager ringManager;
Ringtone ring;
Cursor cursor;

void setup() {
  size(screenWidth, screenHeight, A2D);
  ringManager = new RingtoneManager(this);
  cursor = ringManager.getCursor();
  maxN = cursor.getCount();  
  ring = ringManager.getRingtone(0);  
}


int maxN;
int n = 1;

void draw() {  ;  }


void mouseReleased(){
  if(ring.isPlaying()){
    ring.stop();
    ring = ringManager.getRingtone(n);
    n = (n < maxN-1)? n+1 : 0;
  }else{ 
    ring.play();
  }
}

Enjoy it.