Organizational Research By

Surprising Reserch Topic questions - Question:play an audio file from jar resource with android

if I have this method in a jar library:

public void playAudioFile()
  ClassLoader cLoader = getClass().getClassLoader();
  URL url = cLoader.getResource("audio.mp3"); // in the resource of the jar library

  MediaPlayer mediaPlayer = new MediaPlayer();

After compiling the library, I have: MySDK.jar

When I add the MySDK.jar into my android application and try to play an audio file:

private void playAudio()
   MySDK.Audio audio = new MySDK.Audio();

After compiling the android application, I have: mysampleapp.apk

When debugging the application, the audio file can't be played because:




The path of the audio should be from the jar file not from the sample app. Therefore, the audio file can not be played.

What did I do wrong and how can I play an audio file as a resource file from the jar library?

Thanks in advance.

asked Sep 13, 2013 in ANDROID by rajesh
edited Sep 12, 2013
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.