final String url = entry.getURL();
try {
player = Manager.createPlayer(url);
} catch (final Exception e) {
throw new MediaActionException("unable to load media from "
+ url + ": " + e);
}
_handler.setPlayer(player);
player.addPlayerListener(_handler);
try {
player.realize();
} catch (final Exception e) {
throw new MediaActionException("unable to fetch media: " + e);
}
// Cause playback to begin as soon as possible once start()
// is called on the Player.
final StreamingBufferControl sbc =
(StreamingBufferControl) player
.getControl("net.rim.device.api.media.control.StreamingBufferControl");
sbc.setBufferTime(0);
Control control = player.getControl("VolumeControl");
if (control instanceof VolumeControl) {
final VolumeControl volumeControl = (VolumeControl) control;
_handler.setVolumeController(volumeControl);
// Unmute the application on the assumption that if the user
// asks to
// play a track they actually want to hear it.
try {
doMute(false);
} catch (final Exception e) {
_handler.setVolumeController(null);
control = null;
}
// Set the volume to match the last-selected level
try {
_handler.changeVolume(_handler.getVolume());
} catch (final Exception e) {
_handler.setVolumeController(null);
control = null;
}
}
}
if (player != null) {
try {
player.start();
} catch (final Exception e) {
throw new MediaActionException("unable start player: " + e);
}
}
return true;
}