I’m building an android app where I basically implement a music player from a web content provider.
In a nutshell, I have a player, with “play”, “pause”, “stop” playing. At the same time I am using a new thread to provide progress information on a seek bar, and textView with length, and time played.
I would like to ask your advice on the best aproach on threading. I’d like to pause the thread when paused is pressed, stop it when stop is pressed and resume/start it when play is pressed.
I have something like this:
Thread thread = new Thread(new Runnable()
{
public void run()
{
while(!finished && !stopped)
{//Do some action on Views...}}
And even so, will the thread be completely dead when I leave my app? Won’t it be still running?
Thank you very much, and sorry if this is answered elsewhere.
I use Handler+Broadcast in my mediaPlayerDemo.
The MediaPlayer runs in a Service and use handler.post(runnable) to make a circle.
In Runnable I sendBroadcast() and change the textView when onReceive in my Activity
Like this
You can add if(mp.isPlaying){} to avoid consume when the mediaplayer pause or stop.