Play .mp3 hosted on googledrive with android

0

I've been looking for information for several days, I'm making an app to play music and I need to play .mp3 files that are hosted on my Google Drive, Dropbox account or anywhere to store files in the cloud. if you could pass me some information it will be of great help.

    
asked by Lucho Juniors 24.04.2018 в 01:35
source

1 answer

1

I recommend that at the time of formulating you be more specific or at least show something that you have done, this is where we start. Also, I was recently working with MediaPlayer, the Android class to play audios. I recommend you read the documentation or try to follow this good tutorial . Here is an example of a test I have done with a file of mine hosted in the cloud.

//play from url
public void playURL(){

    String finalURL = "https://drive.google.com/open?id=1cEhQvS5Nmnsynvlt44EYhi3cdWC-tSJX";

    if (player == null){
        Log.d(Constants.AUDIO_LOG_TAG, "Player is null. Call init() before using it! ");
        return;
    }
    try {
       player.reset();
        Log.d(Constants.AUDIO_LOG_TAG, "Playing from url: " + finalURL);
        player.setDataSource(finalURL);
        player.prepareAsync();
    } catch (Exception e) {
        Log.e(Constants.AUDIO_LOG_TAG, "Error playing file " + finalURL, e);
    }

I repeat, first look at all the MediaPlayer documentation because there is a lot of relevant information: MediaPlayer states, callbacks, what is reset, release ... etc.

I hope you have been helpful.

    
answered by 25.04.2018 в 09:56