You can check this answer: Set lock screen background in Android (like Spotify do)
And also this sample app written by google worked for me to understand what happens, it may also help you to understand about your music application. https://android.googlesource.com/platform/development/+/master/samples/RandomMusicPlayer
EDIT: About the random music player, you need to create a new project and move the classes and resources to make it work simply.