Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Media Player Threading

I have written a Music player app and it works great but when a flip action happens or when I return the the player view I have to stop the player and restart it at the postion that it was at when the action happened. That all works but it means a breif stop and start.

How can I run the media player in a different thread and still update my seekbar?

Thanks

like image 253
shaneburgess Avatar asked Jul 06 '10 16:07

shaneburgess


1 Answers

Try running the media player within a foreground service. It's a little bit of work, but it's how it should be done anyways.

The service will handle running everything in a background thread and can be set up to post updates to your UI through messages or callbacks.

In addition, a Foreground service does not need to be tied to an activity, so it can continue to run even if you leave your player screen. The service must provide an Ongoing notification to the user that will probably display the current song, artist, click to pause, etc.

like image 61
CodeFusionMobile Avatar answered Sep 27 '22 18:09

CodeFusionMobile