FAQ

  1. What do I do if I want to play music?

    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.

  2. How about if I want to make an actual music playing app where the user can select music from their library to play.

    This is also made easy for us by Android. On the Android Studio palette, you can drag a MediaController widget, which not only allows your user to control music playback but video as well. Find out how to use this widget on the Android developer site, http://developer.android.com/reference/android/widget/MediaController.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.224