因此我在线上找到了此代码,但是由于某种原因,它无法正常工作。我的意思是它没有崩溃但只是无法播放文件 代码:
import android.media.MediaPlayer;
import android.content.res.AssetFileDescriptor;
import android.content.Context;
import android.app.Activity;
/////////////////////////////////////////////////////////
MediaPlayer mp;
Context context;
Activity act;
AssetFileDescriptor afd;
void setup() {
act = this.getActivity();
context = act.getApplicationContext();
try {
mp = new MediaPlayer();
afd = context.getAssets().openFd("calm1.mp3");//which is in the data folder
mp.setDataSource(afd.getFileDescriptor());
mp.prepare();
}
catch(IOException e) {
println("file did not load"+e);
}
mp.start();
};
void draw() {
};
,输出为:
file did not load java.io.FileNotFoundException: calm1.mp3
pssst im使用处理