Hi,
I am using the following code to play a mp4 file. But i always get an exception:
AUDIOMANAGER: IOException. I dont understand y this error has been coming. I am using BB Curve 8300, OS: 4.5. The audio file is bundled with the cod.
Please help me.
Code:
public class AudioAlert {
private static Player playerWav ;
private static boolean isWavSupported ;
public void playBeep(){
if(isWavSupported){
try{
playerWav.realize();
playerWav.prefetch();/
playerWav.start();
}catch(MediaException ex){
System.out.println("Exception: " + ex.toString());
}
}
}
public AudioAlert() {
String types[] = Manager.getSupportedContentTypes(null);
for (int cnt = types.length - 1; cnt >= 0; --cnt) {
if (types[cnt].equals("audio/mp4")) {
try {
Class clazz = Class.forName("com.rim.samples.device.myapp.myappmain");
InputStream is = clazz.getResourceAsStream("/Alarm.mp4");
playerWav = Manager.createPlayer(is, "audio/mp4");
isWavSupported = true ;
break ;
} catch (MediaException ex) {
System.out.println("Exception: " + ex.toString());
}catch(Exception e){
System.out.println("Exception: " + e.toString());
}
}
}
}
}
or suggest by which i can play the audio file in my app.