user2396965
user2396965

Reputation:

No sound on BlackBerry with openfl

I try to use haxe (openfl) for blackberry development. And I test PlayingSound sample - it works. But when I try to load sound from url - doesn't work.

Here is my code:

public function PlaySong(url:String):Void{
    var _url:URLRequest = new URLRequest(url);                      
    if (_soundChannel != null) _soundChannel.stop();                
    _song = new Sound();
    _song.load(_url); //<--Do not work
    //_song = Assets.getSound("assets/stars.mp3"); <--work
    _soundChannel =_song.play(0);           
}   

In the flash target this code is playing my sound from the url, but when I deploy app to my device - it have no sound. On the device, sound is playing correctly only if I load it from the asset folder. Also, I see that soundChannel position is always 0 (on device);

I try firstly to load the sound with loader, and then play it, when the loading is complete, but it's not help me too.

Help me, please.

PS Sorry for my English.

Upvotes: 0

Views: 244

Answers (1)

AS3Boyan
AS3Boyan

Reputation: 149

Have you tried loading it using this:

var loader:URLLoader = URLLoader(new URLRequest("url"));
loader.data = DataFormat.BINARY;

then try

loader.addEventListener(Event.COMPLETE, onComplete);

function onComplete(e:Event):Void
{
    sound.loadCompressedDataFromByteArray(e.data.content)
}

Try to load bytes first, then create sound from that. Anyway, if your code works on other mobile devices(maybe emulators), then create new issue here: https://github.com/openfl/openfl

Upvotes: 0

Related Questions