Immediate sound feedback on Android

Roger Eller roger.e.eller at sealedair.com
Wed Jun 1 14:13:08 EDT 2011


On Wed, Jun 1, 2011 at 1:29 PM, J. Landman Gay wrote:
>
> On 6/1/11 6:23 AM, Roger Eller wrote:
>>
>> I can't get sounds to play at all on Android.  I have tried importing a .wav
>> file into the stack, and also referencing the file via its path.  In both
>> cases, there is a delay the first time the sound is played in the LiveCode
>> IDE.  How can I insure the playback will be "immediate" when a button is
>> touched?  Is there a best practice regarding embedding sounds -vs-
>> referencing them for mobile?
>
> Embedded sounds don't work well, use sound files on disk instead. Include
> them in the Copy Files pane of the standalone builder, with or without an
> enclosing subfolder. When playing the sound, use the whole file path,
> starting with specialFolderPath("engine").
>
> Since you are getting a delay, it sounds like the sounds are being found
> okay, but you are experiencing the initial loading of Android's sound playback
> system. To get around that, I'd try preloading it early in the launch sequence,
> maybe on openstack. I haven't actually tried this yet, but I think it will work.
> Get the current playLoudness and save it in a variable, set the playLoudness
> to zero, play one of your sounds (which you won't hear) and then reset the
> playLoudness to its initial value.
>
> If it works let us know, I've been meaning to try it but I haven't had time to work
> on my test stack lately.
>
> --
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
>

Jacq,

When I check the playLoudness, it is 100.  It doesn't matter if I have
the volume turned all the way down, it still returns 100.  So, I set
the playLoudness to 0, play my sound, then set the playLoudness to 100
again in openStack.

On my device, I can still hear the sound play on openStack, but is is
at least cached, so further use of the sound is immediate.  I think
the playLoudness always at 100 is a bug.  I believe your approach
should have worked otherwise.

~Roger




More information about the use-livecode mailing list