02-17-2012 08:47 PM - last edited on 02-17-2012 08:58 PM
[Sorry, this has nothing to do with Android - I posted it to the wrong forum by mistake ... Just asked the moderator to move it.]
I just tested my unfinished app in a 2.0 Simulator and found one problem with the sound. Does anybody know if sound handling has changed somehow, or is it just a simulator problem?
In particular I'm setting the volume with
AudioManager.audioManager.setOutputLevel(vol);
which works fine both on my 1.0.8 device and in the 1.0 Simulator, but in the 2.0 Simulator (2.0.0-7109-Win) the sound plays just very faintly, no matter what volume I set.
Cheers
Anna
Solved! Go to Solution.
02-20-2012 11:02 AM
I just noticed that the volume slider under Options > Sound & Notifications also has absolutely no effect on the volume of my sounds (whether it's on mute or 100%, it's always just about audible if I lean my ear towards the speaker). So to me that looks like a simulator issue, but I'd be interested to hear from anyone else who uses sound and has tried it under 2.0 (device or simulator) ...
02-21-2012 05:16 PM
There aren't any known issues with this API. Can you provide a more complete code sample so that I can reproduce this here? A sample audio clip or a link to one from the internet that reproduces it would also be appreciated.
Thanks
02-22-2012 10:20 PM
Thanks for looking into this, Tim!
I have just put a very simple test class together: it loads a piece of music from the Internet (doesn't matter which sound though, you can replace the path with something local if you want), sets the device volume to 50% and then plays the music.
When I load this onto my PlayBook (1.0.8) or my old 1.0.6 Simulator, it works as expected: no matter what the volume was set to before in the device settings, the music plays at medium volume, and when you open the device settings > Sounds I see the slider has moved to about 50%. Moving the slider by up or down by hand, obvioiusly changes the music's volume .
When I load it in the 2.0 Simulator 2.0.0.7109, the music only plays barely audible, and the volume slider in the device settings is a) unaffected by the audio.setOutputLevel(50) command, and b) when I move it manually there is also no effect on the actual volume of the music.
Here is the code: (compile it with set_audio_volume and play_audio permissions)
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.text.TextField;
import qnx.system.AudioManager;
[SWF(height="600", width="1024", frameRate="30", backgroundColor="#cccccc")]
public class SoundTest extends Sprite
{
private var snd:Sound;
private var msg:TextField = new TextField();
private var audio:AudioManager = AudioManager.audioManager;
private var globalVolume:Number = -1; // -1 means not stored yet
private var globalMute:Boolean;
public function SoundTest()
{
super();
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
addChild(msg);
getSound();
}
private function getSound():void
{
// create a sound to check if the file is valid & access ID3 info if necessary
var url:URLRequest = new URLRequest("http://www.danosongs.com/music/danosongs.com-gentl y.mp3");
snd = new Sound();
// listen for success or error
snd.addEventListener(IOErrorEvent.IO_ERROR, onSoundError);
snd.addEventListener(Event.COMPLETE, onSoundSuccess);
snd.load(url);
msg.text = "loading sound ...";
}
protected function onSoundSuccess(event:Event):void
{
msg.text = "playing";
// set the volume to mid-range
// NOTE: contrary to QNX documentation, setOutputLevel takes values between 0 and 100 (not 0 and 1)
audio.setOutputMute(false);
audio.setOutputLevel(50);
//play the sound
var channel:SoundChannel = snd.play(0);
}
protected function onSoundError(event:IOErrorEvent):void
{
msg.text = "error";
}
}
}
BTW, is there a reason that the main RIM simulator page ( http://us.blackberry.com/developers/resources/simu
Thanks
Anna
02-23-2012 11:40 AM
Update: I just installed 2.0 on my PlayBook and it's working perfectly phew! :-)
So all that remains would be to check if there is a problem with the 2.0 simulator, or if it's just my installation of it that's somehow messed up ...
02-23-2012 11:49 AM
Likely it was a bug that was fixed later than the last simulator build. We have the launch version of 2.0 on a simulator coming shortly. I was told the 28th is the day.