'Android: How to host media player as a service?

I have an app with a playlist and a media player UI.

The issue I am having is when I am playing music, and I re-enter the activity (using a menu), it restarts the media file (because it is calling the onCreate method from the top).

I need to implement the mediaplayer as a servive instead but I have no idea on how to do this! Everywhere I look online is just non-relevant and super confusing articles/code.

Can anyone assist with helpful tutorials or articles related to this?

My code can be found here: https://github.com/becausewesley/MusicalStructureApp

THANKS IN ADVANCE!!



Solution 1:[1]

This article Creating Media player service shows step by step on how you can implement a service to create a Mediaplayer application to run in the background. Hope this helps!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community