December 2015
Beginner
698 pages
15h 16m
English
You can play some music in the background of your app using the MediaPlayer class. Here is some sample code to show how simple this can be:
// Create a MediaPlayer object MediaPlayer mp = new MediaPlayer(); // Choose where to load the music from mp.setDataSource(musicFileToLoad); // Call the prepare method mp.prepare(); // Play some music mp.start();
Take a look at the official documentation for full details at http://developer.android.com/reference/android/media/MediaPlayer.html.
This is also made easy for us by Android. On the Android Studio palette, you can drag a MediaController widget, which ...
Read now
Unlock full access