@@ -0,0 +1,2741 @@
+package com.beepscore.android.spotifystreamer;%0A%0Aimport android.content.Context;%0Aimport android.media.AudioManager;%0Aimport android.media.MediaPlayer;%0Aimport android.util.Log;%0A%0Aimport java.io.IOException;%0A%0A/**%0A * Created by stevebaker on 8/13/15.%0A * References%0A * https://developer.android.com/reference/android/media/MediaPlayer.html%0A *%0A * book %22Android Programming%22, The Big Nerd Ranch Guide%0A * authors Bill Phillips, Brian Hardy%0A * http://www.bignerdranch.com/we-write/android-programming%0A * Chapters 13-15%0A * HelloMoon%0A * https://github.com/beepscore/HelloMoon.git%0A */%0A//public class AudioPlayer %7B%0Apublic class AudioPlayer%0A        implements MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener %7B%0A%0A    private final String LOG_TAG = AudioPlayer.class.getSimpleName();%0A%0A    private MediaPlayer mMediaPlayer;%0A%0A    public void play(Context c, String url) throws IllegalArgumentException, IOException %7B%0A%0A        // prevent creation of multiple media players.%0A        if (mMediaPlayer == null) %7B%0A            mMediaPlayer = new MediaPlayer();%0A            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);%0A%0A            mMediaPlayer.setOnErrorListener(this);%0A            // Caution: You must either catch or pass IllegalArgumentException and IOException when using setDataSource(),%0A            // because the file you are referencing might not exist.%0A            mMediaPlayer.setDataSource(url);%0A%0A            // as soon as playback is done, call stop to release media player%0A            mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() %7B%0A                @Override%0A                public void onCompletion(MediaPlayer mMediaPlayer) %7B%0A                    stop();%0A                %7D%0A            %7D);%0A%0A            mMediaPlayer.setOnPreparedListener(this);%0A            mMediaPlayer.prepareAsync();%0A        %7D%0A    %7D%0A%0A    @Override%0A    // http://developer.android.com/reference/android/media/MediaPlayer.OnErrorListener.html%0A    public boolean onError(MediaPlayer player, int what, int extra) %7B%0A        // ... react appropriately ...%0A        // The MediaPlayer has moved to the Error state, must be reset!%0A        Log.e(LOG_TAG, %22MediaPlayer error, resetting%22);%0A        player.reset();%0A%0A        // return true to indicate method handled the error%0A        return true;%0A    %7D%0A%0A    /** Called when MediaPlayer is ready%0A     * http://developer.android.com/reference/android/media/MediaPlayer.OnPreparedListener.html%0A     */%0A    public void onPrepared(MediaPlayer player) %7B%0A%0A        player.start();%0A    %7D%0A%0A    public void pause() %7B%0A        mMediaPlayer.pause();%0A    %7D%0A%0A    public void stop() %7B%0A        if (mMediaPlayer != null) %7B%0A            mMediaPlayer.release();%0A            mMediaPlayer = null;%0A        %7D%0A%0A    %7D%0A%0A%7D

Add AudioPlayer.java