It looks like your code would constantly circle through your while loop during a song. This is known as a 'busy wait', and is a faux pas in code. I recommend you set a Timer instead.
Yusuf Saib Android ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Aug 9, 11:54 am, androidom <[email protected]> wrote: > Hi there, > I am trying to set the background dynamically as I play music. > > 1) I am able to set the background using the setBackground > (Color.GREEN) method. > 2) Then I play a MP3 file (audio) using the MediaPlayer. > 3) when I call myPlayer().isPlaying(), I would like to keep changing > the background color continiously till the music stops. I tried this > way, > > setContentView(R.layout.main); > //startStreamingAudio(); > tv = new TextView(this); > tv.setBackgroundColor(Color.GREEN); > tv.setTextColor(Color.WHITE); > tv.setText("Do you hear me!"); > setContentView(tv); > mp = MediaPlayer.create(getApplicationContext(), > R.raw.organ_1); > mp.start(); > while(mp.isPlaying()){ > i += 20; > tv.setBackgroundColor(Color.rgb(i, 100, 100)); > setContentView(tv); > } > > It changes only at the end of the sound file. Can someone help me find > the right way towards this ? > thanks > Di --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

