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

Adobe AIR Development

Reply
New Contributor
kay_siegert
Posts: 9
Registered: ‎01-14-2011
My Device: Not Specified

Sound support on emulator

Hi,

as far as I could find out, the current emulator doesn´t support sound. Is that correct?

I´ve developed a music app. The sounds seem to load correctly but I can´t hear them.

 

Is it just an emulator problem? Will it play on the live device?

 

Thanks,

Kay

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Sound support on emulator

What platform are you using (Mac, etc)?

 

What APIs are you using to play the sound?

 

I can confirm that "raw" sound generated using flash.media.Sound and the SampleDataEvent does work. 

 

I don't believe I've yet seen a code snippet showing how to get any other sound to work.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
shawnblais
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Sound support on emulator

I can verify that mp3's loaded from an HTTP server, using Sound.load() do work.

 

But the entire simulator locked right afterwards (song kept playing though) 

Please use plain text.
New Contributor
kay_siegert
Posts: 9
Registered: ‎01-14-2011
My Device: Not Specified

Re: Sound support on emulator

Thanks, after the simulator update everything works fine, almost (but that requires a separate thread.

 

Kay

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Sound support on emulator

Here's a sample that works fairly consistently on mine.  I have had freezes (requiring VM reset) but so far it looks like those may be associated with installing an updated app while the current one is still running.  At least, it looksl like if I cleanly exit the app before starting to install/launch a changed version it doesn't seem to crash (much?).

 

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;

    [SWF(backgroundColor="#dddddd", frameRate="20")]
    public class SoundTest extends Sprite {
        public function SoundTest() {
            var request:URLRequest = new URLRequest('http://www.tekyo.com/medias/Scotland the Brave.mp3');
            var sound:Sound = new Sound();
            sound.load(request);
            var channel:SoundChannel = sound.play();
            channel.addEventListener(Event.SOUND_COMPLETE, onComplete);
        }

        private function onComplete(e:Event):void {
            stage.nativeWindow.close();
        }
    }
}

 Note that the volume seems to be about half what it is with programs on my host machine.  I have no idea if that's VMware itself or something in the simulator.

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
biggerCC
Posts: 270
Registered: ‎12-13-2010
My Device: PlayBook 16GB, BB10 Dev Alpha
My Carrier: o2 (de)

Re: Sound support on emulator

Thanks for sharing your code, Peter.

One additional question: I already figured out, that I can stop playback with

 

channel.stop()

But once stopped I won't be able to restart it. I tried making sound and channel global variables, but calling channel=sound.play() again and even making a new URLRequest with loading the MP3 again did not work.

 

 

Any ideas?

- - -
My approved apps @ App World
Please use plain text.
Developer
tags07
Posts: 386
Registered: ‎12-12-2010
My Device: BB Style
My Carrier: Sprint

Re: Sound support on emulator

@biggerCC: I had similar issue...i can play the mp3 but after a while sound stops working i need to reboot to have it working again.. 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Sound support on emulator

Even with my app, which generates raw sound using SampleDataEvent, I find that the sound just stops coming out after a longish period of time (sometimes a few hours), for no visible reason.  There are no exceptions, no related bugs in my app, no memory leaks, no change in the status of the sound buffers in the simulator's /tmp folder, or any other sign of a problem other than it goes silent.  (I have not yet checked whether there's a change in threads running by checking the output of "pidin".)

 

I've just been assuming this will work on the real hardware.  It's a pretty safe bet, I think, given how many issues the simulator has, that both this and any issues with MP3 playing are just sim bugs.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.