skip to Main Content

I have developed an android music player app. That Play music from local storage

I would like to add online streaming options like Spotify,Gana. Etc….

Im not a professional android developer I’ve developed the app based on other music player source code

So anyone can help me how to add Spotify api or other options…

2

Answers


  1. Using the following code might help you. But I recommend you use google ExoPlayer as it has more features than MediaPlayer from android.

     MediaPlayer mp = new MediaPlayer(); 
     mp.setDataSource(context,Uri.parse("your url")); 
     mp.prepare(); 
     mp.start();
    

    Check that for Google ExoPlayer
    ExoPlayer Documentation

    Login or Signup to reply.
  2. Do you mean to play Spotify music in your app? This is usually not possible, because music requires authorization, but if you have an audio file, you can put it in the cloud and use the following code to play it.

    MediaPlayer mediaPlayer = new MediaPlayer(); 
    mediaPlayer.setDataSource(applicationContext, Uri.parse("music url"))
    mediaPlayer.setOnPreparedListener { it.start() }
    mediaPlayer.prepareAsync()
    

    Alternative plan

    The Spotify SDK allows your application to interact with the Spotify app running in the background as a service. The capabilities of this API include getting metadata for the currently playing track and context, issuing basic playback commands and initiating playback of tracks.

    Please refer to: https://developer.spotify.com/documentation/android/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search