Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Specify Audio Path Routing

by BlackBerry Development Advisor ‎02-16-2010 02:48 PM - edited ‎09-16-2010 03:27 PM (2,638 Views)

Summary

 

This article applies to the following:

 

  • BlackBerry® Device Software 4.2
  • BlackBerry® Java® Development Environment 4.2.0


Description


The AudioPathControl interface in the BlackBerry smartphone application programming interface (API) set allows an application to specify the route that is used to play back or record audio. This means your application could play back and/or record audio using a specified speaker and microphone. For example, you can specify the speaker and microphone built into the BlackBerry smartphone, a Bluetooth® headset, or a wired headset.

 

The following portion of code shows how to route audio to a Bluetooth headset:

 

 

try {
Player p =
javax.microedition.media.Manager.createPlayer("http://mycompany/test.mp3");
p.realize();
p.prefetch();
Control[] c = p.getControls();
for(int i=c.length-1; i>=0; --i) {
if(c[i] instanceof AudioPathControl) {
AudioPathControl apc = (AudioPathControl)c[i];

try{
//Route the audio to Bluetooth. For more
audio path options see the AudioPathControl javadocs.
apc.setAudioPath(AudioPathControl.AUDIO_PATH_BLUETOOTH);
} catch(Exception e) {
System.err.println(e.toString()); }
}
}
p.start();
}
catch(Exception e) { System.err.println(e.toString());
}

 

Contributors
Users Online
Currently online: 30 members 1,031 guests
Please welcome our newest community members: