Code example for MediaPlayer

Methods: prepareAsyncsetDataSource

1
            Log.i(TAG, "Playing track at URL=["+audioTrackURL+"]");
            mAudioTrackURL = audioTrackURL;
 
            if (mAudioSrvState == NOT_PLAYING) {
                try { 
                    mMediaPlayer.setDataSource(mAudioTrackURL);
                    mMediaPlayer.prepareAsync();
                } catch (IllegalArgumentException e) {
                    Log.e(TAG, "AudioTrackUrl seems to be incorrectly formatted",e);
                } catch (IllegalStateException e) {
                    Log.e(TAG, "MediaPlayer is in an illegal state",e);
                } catch (IOException e) {
                    Log.e(TAG, "MediaPlayer failed due to exception",e);
                } 
            } 
             
        } 
         
        public void stop() { 
            Log.i(TAG, "Call to stop streaming audio");
Stop searching for code, let great code find you!  Add Codota to your java IDE