Music player code in android :-
Android is the best platform for creating mobile application like music play. It is really easier than creating app in other mobile operating system.
To play a music in android application,you need to create object of MediaPlayer class.
Steps to create music player code for android :-
Use following steps to play any music in your android application
- Create “raw” folder in “res” folder of your project.
- Copy any music file from your computer, then paste this file in “raw” folder that you created.
- Remove extension associated with music file means if it is music.mp3 then rename it as music only.
- Now take two button in xml layout file one for play and other for stop
- Now define onClick() event for start button and write following code
- Now define onClick() event for stop button and write following code.
¡MediaPlayer mp=MediaPlayer.create(this, R.raw.one);
Full android web application Tutorial:-