Create a Simple Music Player App in Android Studio

Music is a part of every person’s life. No matter what your mood is, you have a song to sustain that mood. If you wish to play your desired songs on Android devices, you need a music player. So, through this article, we will try to build our music player app using Android.

About Music Player App:

The music player app that we will develop in this article would allow the users to play the songs present on the device. You can download songs on your device and then use the music player to play those songs. Let’s see the quite exciting features that you get along with this app.

Features of Music Player App:

1. Alluring user interface with loaded animations and music bars.
2. You can access all the songs present on your device.
3. Play your songs on the go without even having an internet connection.
4. Play or pause your music.
5. Listen to music even on your device background—no need to keep the app open all the time.
6. Music Visualizer that helps you to visualize the beats of a song.

The flow of the application:

Now, let’s see the screens you need to build as a part of the Music Player App.

  • Home Screen – You need to develop a home screen of the music app where the users can see all the available music that they can listen to.
  • Music Player Screen – You need to build a screen having features like play/pause a song, forward/backward animations, and running music bars.

Project Requirements:

To build the music player applications, you need not be an expert but should be familiar with a few concepts. If you are good at designing layouts, you can make your music more alluring and attractive. Let’s see the concepts that are essential to know to build the music player project.

1. Android Studio and its tools
2. Android XML Layout Designing
3. Android Activities and LifeCycle
4. Android RecyclerView or ListView
5. Android Event Handler
6. Android Animations
7. Android Services
8. Java and Object-Oriented Programming

Download Music Player Android App Code

Please download the source code of android music player app: Music Player Android App Code

Getting Ready for the Project:

Now, let’s see the files that are present in the Android Music Player App. These files are important for understanding the music player project and then applying your customizations to the project.

  • Android Manifest – The AndroidManifest.xml file consists of all the required permissions and declarations essential for the music player app to run smoothly. Below are the permissions that we have kept in the music player application.

Code:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  • Android Gradle File – The Android Gradle file contains dependencies of the libraries you intend to use in your music player app. Below are the dependencies that we used to build the music player app.

Code:

//For Checking permissions
implementation 'com.karumi:dexter:6.2.3'

//To Visualize Music
implementation 'com.gauravk.audiovisualizer:audiovisualizer:0.9.2'
  • MainActivity – The MainActivity, as we know, is the parent activity for our music application that eventually loads up at the start of the application.
  • Android Resources – Various Android resources are used in your layouts, apply distinct colors, and define static strings.

Steps to implement the Project:

As you have gathered some insights about the music player app we will develop today, let’s see the actual implementation in Android. The actual implementation of the music player application is quite simple. To make it easier, we have provided the source code of the Music Player App and necessary comments.

You need to follow the below steps to run the music player project in your system.

1: Follow the download link above and download the source code of the Music Player App.

2: Now locate the zip file and extract the music player project.

3: Now, you need to open your android studio and then click on open an existing project and select the music player project.

4: Now, let the music player project files load and the Gradle sync complete.

5: Now go to your Manifest file and check whether the permission to access the external storage is defined or not.

6: Now, simply open tools and select rebuild the project. It will rebuild the files of your music player app.

Now simply run your music player application on your actual device or emulator.

Android Music Player App Output

Android Music Player Home Screen:

android music player home

Music Player while playing a song:

music player

Summary

From this article, you came to know about how a music player is built using Android Studio. In the objective of doing so, you got to know the features of the music player, its flow, and the requirements to build it. Further, you saw the things you need to know to get started with the development of the music player. Finally, you saw the actual implementation of the music player along with its source code.