Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
boostr.in 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.
Sep 13, 2013
Sep 12, 2013
to add a comment.
Related Hot Questions
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
To avoid this verification in future, please