You can't "upload" your audio file into res/raw.
You can place an audio file in the res/raw folder when you compile
your code and aapt will compile it into the APK along with the code
and other resources. You can then play it by using the MediaPlayer
with code roughly like this:
MediaPlayer mp = null;
AssetFileDescriptor afd = context.getResources().openRawResourceFd
(R.raw.my_audio_file);
if (afd != null) {
mp = MediaPlayer.create();
try {
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset
(), afd.getLength());
mp.prepare();
mp.start();
} catch (java.io.IOException ex) {
mp.release();
mp = null;
}
}
// log an error for debugging purposes
if (mp == null) {
Log.e("Error playing my_audio_file.mp3 from res/raw");
}
When you are done playing the file, make sure you call mp.release() to
release the MediaPlayer resources.
On Feb 10, 1:36 am, jaimin <[email protected]> wrote:
> hi.
> i am new to android and i want devlop a mediaplayer so i want to
> upload my audio file into my res/raw folder so how can i upload my
> audio file into res/raw folder in my project .
> anyone have any suggestion ?
> plz give me suggestion i need it very badly .
> thanks.
> jaimin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---