Loading...
Logo
Processing Forum

Android mediaplayer

in Android Processing  •  8 months ago  
I'm  in a bit of a rush posting this sorry about any mistakes. How do I access an .ogg file in my data folder using the mediaplayer? I don't know how to create a res/raw folder. I'm I suppose to? Here's what I've tried. I've commented out the lines that throw IO exceptions.

Copy code
  1. import android.media.MediaPlayer;
  2. import android.media.AudioManager;
  3. MediaPlayer MPyeah;
  4. boolean bFirstRun;
  5. void setup()
  6. {
  7.   size(displayWidth, displayHeight);
  8.   MPyeah = new MediaPlayer();
  9.   //MPyeah.setDataSource("r.ogg");
  10.   background(255);
  11.   fill(80);
  12. }
  13. void draw()
  14. {
  15.   background(255);
  16.   if(bFirstRun)
  17.   {
  18.     //MPyeah.prepare();
  19.     //MPyeah.start();
  20.   }
  21.   bFirstRun = false;
  22. }
please help. Also I don't really want to use additional third party libraries.

Replies(2)

You don't have to create a res folder, its done for you. ANything you put in /data gets compiled into /res
The very nice code written on this post which is really useful for so many peoples. I will try to use this code to improve media player. If you need any help regarding Android apps then visit our website.