Quantcast
Channel: The Echo Nest Developer Forum
Viewing all articles
Browse latest Browse all 1582

Android EchoNest API

$
0
0

package com.example.berten.zotteshit; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import com.echonest.api.v4.EchoNestAPI; import com.echonest.api.v4.EchoNestException; import com.echonest.api.v4.Track; import java.io.File;

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

        double bpm = getTempo();

}

public double getTempo () throws EchoNestException  {
    EchoNestAPI echoNest = new EchoNestAPI("myapikey");
    File mp3 = new File("/storage/sdcard1/Muziek/Tomorrowland/204-sebjak_and_marcus_schossow_-_liceu.mp3");

     Track track = echoNest.uploadTrack(mp3,false);

    track.waitForAnalysis(30000);
    double tempo = track.getTempo();
    return  tempo;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

I'm trying to make an application which can upload a song to the echonest API and then receive the tempo of a song. But I get 2 errors using this code: Java.io.IOException com.echonest.api.v4.EchoNestException

Thanks in advance :)


Viewing all articles
Browse latest Browse all 1582

Trending Articles