Play sound in Android mode for Processing:
There are 2 libraries that both can work for now(2017/02/21), also remember to update your android mode if things not working. You can try any one of them to see if it works in your situation.
To download cassette library at https://github.com/shlomihod/cassette .
To download apwidgets library at https://github.com/barefists/APmediaPlayer .
Unzip those files and remember to change their directory name to cassette/apwodgets and put them in your Sketchbook libraries.
Then reopen Processing you should see them now in your Sketch->import Library .
If you find this article in many years later then this article written, chances are these 2 libraries are not working for your new Processing or Android mode, or the download links are not available, so you should try to find if there are any newer versions.
cassette的語法大致如下:
Example for cassette:
import cassette.audiofiles.SoundFile;
SoundFile player;
void setup() {
background(255, 0, 0);
player = new SoundFile(this, "test.wav"); /*這個要放在自己設的 data 目錄裡面。Remember to place sound file at directory named data, if there is no data directory in your project directory then you should make one. */
player.loop();
}
void draw() {
}
void mousePressed() {
player.stop();
}
apwidgets的語法大致如下:
Example for cassette:
import apwidgets.*;
APMediaPlayer player;
void setup(){
player = new APMediaPlayer(this);
player.setMediaFile("test.mp3");
player.start();
}
void draw(){
background(255,255,0);
}
void mousePressed(){
player.pause();
player.release();
} 作者: processor 時間: 2017-2-23 23:40
Some related discussion threads: