EZMusicBoxSDK/src/main/java/com/wms/ezmusicbox/sdk/streaming/StreamingMediaPlayer.java
/**
     * Test whether we need to transfer buffered data to the MediaPlayer.
     * Interacting with MediaPlayer on non-main UI thread can cause crash so perform this using a Handler.
     */
Test whether we need to transfer buffered data to the MediaPlayer.
Interacting with MediaPlayer on non-main UI thread can cause crash so perform this using a Handler.
Test whether we need to transfer buffered data to the MediaPlayer . Interacting with MediaPlayer on non - main UI thread can cause crash so perform this using a Handler .
private void  testMediaBuffer() {
	    Runnable updater = new Runnable() {
	        public void run() {
	            if (mediaPlayer == null) {
	            	if ( totalKBRead >= INTIAL_KB_BUFFER) {
	            		try {
		            		startMediaPlayer();
	            		}
			            catch (Exception e) {
	            			Log.e(getClass().getName(), "Error copying buffered content.", e);
	            		}
	            	}
	            }
	            else if ( mediaPlayer.getDuration() - mediaPlayer.getCurrentPosition() <= 1000 ){
	            	transferBufferToMediaPlayer();
	            }
	        }
	    };
	    handler.post(updater);
    }
private void testMediaBuffer ( ) { Runnable updater = new Runnable ( ) { public void run ( ) { if ( mediaPlayer == null ) { if ( totalKBRead >= INTIAL_KB_BUFFER ) { try { startMediaPlayer ( ) ; } catch ( Exception e ) { Log . e ( getClass ( ) . getName ( ) , "Error copying buffered content." , e ) ; } } } else if ( mediaPlayer . getDuration ( ) - mediaPlayer . getCurrentPosition ( ) <= 1000 ) { transferBufferToMediaPlayer ( ) ; } } } ; handler . post ( updater ) ; }
Test whether we need to transfer buffered data to the MediaPlayer.
Test whether we need to transfer buffered data to the MediaPlayer .
//  Only create the media player once we have the minimum buffered data //  NOTE:  The media player has stopped at the end so transfer any existing buffered data. //  We test for < 1 second of data because the media player can stop when there is still //  a few milliseconds of data left to play