Why is MediaPlayer playing before TextView setText takes effect?

by Breezy » Tue, 19 Jan 2010 10:41:12 GMT


Sponsored Links
 When a button is clicked the text of a textview changes and a sound is
played, but the sound is played first then the text changes.  I would
like it to happen simultaneously if not then the text to take effect
first.  Here's my code...



        public void playSound(int playingFile)
        {
                        MediaPlayer mp = MediaPlayer.create(getBaseContext(), 
playingFile);
                            mp.start();
                            while(mp.isPlaying())
                            {
                                //i put this in so the mp isn't released in 
middle of the
sound
                            }
                        mp.release();
        }

        public void onClick(View v)
        {
                if(v==button1)
                {

                                maintext.setText("2");
                                maintext.setTextColor(Color.RED);
                                playSound(R.raw.s2);
                }
         }


Can anyone see the problem?  It works, just not as I hoped.  Is there
any way this could be more efficient as well?



Other Threads

1. Import Bulk Data

Hi..

Anyone know's how to import bulk data into a sqlite table through
code?

Thanks,
Immanuel
--~--~---------~--~----~------------~-------~--~----~

2. How to disconnect a call?

Dear All,
I am just try to build a small app to black list certain people such
that as soon as I recieve a call from them, it gets disconnected.

I have written a  PhoneStateListener listener but could not FInd any
method for doing the same in TelephonyManager class.

All I want is a way to disconnect an in coming call.

Any ideas?

Regards,
Sandeep Giri

--~--~---------~--~----~------------~-------~--~----~

3. Developing on Stock T-Mobile G1?

4. getline support?

5. K9mail-errors : host is unresolved : mail.gmail.com:80

6. #2# [NO, Mailbox, does, not, exist]

7. how to turn on the log information in the opencore/codec_v2/omx