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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With