Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Adobe AIR Development

Reply
Developer
apman
Posts: 59
Registered: 11-12-2010
Accepted Solution

AudioManager under OS 2.0

[ Edited ]

[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

Please use plain text.
Developer
apman
Posts: 59
Registered: 11-12-2010

Re: AudioManager under OS 2.0

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) ...

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 288
Registered: 07-15-2008
My Carrier: Bell

Re: AudioManager under OS 2.0

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

Tim Windsor
Application Development Consultant
Please use plain text.
Developer
apman
Posts: 59
Registered: 11-12-2010

Re: AudioManager under OS 2.0

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-gently.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/simulators.jsp ) still doesn't offer a 2.0 simulator download? I found the download only after some hunting around on a page for native SDK devs (https://bdsc.webapps.blackberry.com/native/beta/download) ... 

 

Thanks

Anna

Please use plain text.
Developer
apman
Posts: 59
Registered: 11-12-2010

Re: AudioManager under OS 2.0

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 ...

 

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 288
Registered: 07-15-2008
My Carrier: Bell

Re: AudioManager under OS 2.0

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.

Tim Windsor
Application Development Consultant
Please use plain text.