This is probably not helpful, but:

* did you mean to have the loop value of -1?  (infinite looping sound)
* can you try triggering the sound later, after the load has had a
chance to complete (I believe the sound samples load asynchronously,
but cannot be played until the samples are all squared away).

On Jan 8, 8:25 pm, LysolPionex <[email protected]>
wrote:
> I'm trying to get a sound to play from a widget. The code (below) is a
> near copy of code from another project which successfully plays
> sounds.  The sounds which I use work in other projects, and working
> sounds from other projects also don't play in this project.
>
> I think I just need a pair of fresh eyes.
>
> Thanks for any insight!
>
>       .......
> public void onReceive(Context context, Intent intent){
>
>       .......
>
>   //for deciding which sound to play
>   int soundToPlay;
>
>       .......
>
>    /******************
>     * Play the sound *
>     ******************/
>    //make a sound pool
>    SoundPoolsoundPool= newSoundPool(4, AudioManager.STREAM_MUSIC,
> 0);
>    int soundID =soundPool.load(context, soundToPlay, 1);
>
>   /****************************************************
>    * this showssoundPool.play() returning a 0  *
>    ****************************************************/
>    CharSequence text = soundID + " -> " +soundPool.play(soundID, 1,
> 1, 1, -1, 1);
>    int duration = Toast.LENGTH_SHORT;
>    Toast toast = Toast.makeText(context, text, duration);
>    toast.show();
>
>       .......

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to