MediaBrowserService vs MediaPlayer to play wave files on Android

531 Views Asked by At

In the Android developer guide, under Building an Audio App section, there is a statement:

The preferred architecture for an audio app is a client/server design. The player and its media session are implemented inside a MediaBrowserService, and the UI and media controller live inside an Android activity along with a MediaBrowser.

In the other hand, we have also the MediaPlayer class.

Which way is prefered in which situations?

1

There are 1 best solutions below

0
On

Because such an architecture has multiple advantages mainly because there is a clear separation between the Ui which controls the music service and the music service itself. In this way music service can continue its music service irrespective of the type of the UI client. Different clients can get the active media controller from your Music service and show its own UI. Different apps can attach to your Music service (if you allow) & show different UI depending upon context, like Android Auto.