import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Bundle;
import android.widget.Toast;
import android.app.Activity;
public class MainActivity extends Activity {
private MediaPlayer player;
private long starttime;
private long endtime;
private long fark;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
initalize();
}
private void initalize(){
starttime = System.currentTimeMillis();
player = new MediaPlayer();
try{
player.reset();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource("http://radyo.normworks.com:8005/");
}catch(Exception e){
Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show();
}
player.prepareAsync();
player.setOnPreparedListener(new OnPreparedListener(){
public void onPrepared(MediaPlayer mp){
endtime = System.currentTimeMillis();
player.start();
fark = endtime - starttime;
String m = "Eclipse\nStart : " + starttime + "\nEnd : " + endtime + "\nFark : " + fark ;
Toast.makeText(getBaseContext(),m,Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onDestroy() {
player.stop();
player.release();
super.onDestroy();
}
}