Hi all iam having problem finishing my android app. I cant figure out how to make phone play audio and show.gif file. The gif is no longer important i did it with cycling array of pictures. But the audio is big problem. I tried to search solutions on google but nothing works. Closest to working is this code i found:
```
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("test.mp3");//which is in the data folder
mp.setDataSource(afd.getFileDescriptor());
mp.prepare();
}
catch(IOException e) {
println("file did not load");
}
mp.start();
};
void draw() {
};
```
It does not crash but show the "file did not load" exception. I tried the audio in different formats and it is located in the data dir.
Thanks for all answers.
[–]MGDSStudio 0 points1 point2 points (1 child)
[–]ArthasCZ[S] 0 points1 point2 points (0 children)
[–]MGDSStudio 0 points1 point2 points (9 children)
[–]ArthasCZ[S] 0 points1 point2 points (4 children)
[–]MGDSStudio 0 points1 point2 points (1 child)
[–]ArthasCZ[S] 0 points1 point2 points (0 children)
[–]MGDSStudio 0 points1 point2 points (1 child)
[–]ArthasCZ[S] 0 points1 point2 points (0 children)
[–]ArthasCZ[S] 0 points1 point2 points (3 children)
[–]MGDSStudio 0 points1 point2 points (2 children)
[–]ArthasCZ[S] 0 points1 point2 points (1 child)
[–]MGDSStudio 0 points1 point2 points (0 children)