Search in sources :

Example 1 with AudioAnalysis

use of se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis in project spotify-web-api-java by spotify-web-api-java.

the class GetAudioAnalysisForTrackExample method getAudioAnalysisForTrack_Async.

public static void getAudioAnalysisForTrack_Async() {
    try {
        final CompletableFuture<AudioAnalysis> audioAnalysisFuture = getAudioAnalysisForTrackRequest.executeAsync();
        // Thread free to do other tasks...
        // Example Only. Never block in production code.
        final AudioAnalysis audioAnalysis = audioAnalysisFuture.join();
        System.out.println("Track duration: " + audioAnalysis.getTrack().getDuration());
    } catch (CompletionException e) {
        System.out.println("Error: " + e.getCause().getMessage());
    } catch (CancellationException e) {
        System.out.println("Async operation cancelled.");
    }
}
Also used : AudioAnalysis(se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException)

Example 2 with AudioAnalysis

use of se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis in project spotify-web-api-java by spotify-web-api-java.

the class GetAudioAnalysisForTrackExample method getAudioAnalysisForTrack_Sync.

public static void getAudioAnalysisForTrack_Sync() {
    try {
        final AudioAnalysis audioAnalysis = getAudioAnalysisForTrackRequest.execute();
        System.out.println("Track duration: " + audioAnalysis.getTrack().getDuration());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : AudioAnalysis(se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Aggregations

AudioAnalysis (se.michaelthelin.spotify.model_objects.miscellaneous.AudioAnalysis)2 IOException (java.io.IOException)1 CancellationException (java.util.concurrent.CancellationException)1 CompletionException (java.util.concurrent.CompletionException)1 ParseException (org.apache.hc.core5.http.ParseException)1 SpotifyWebApiException (se.michaelthelin.spotify.exceptions.SpotifyWebApiException)1