Halo Sobat" blog MS3W hari ini kita akan membuat tutorial membuat
Radi Online
1. pertama klik file > new
> android project
2. setelah muncul isi sesuka hati kalian projectnya
3. setelah itu buka src > main activity.java nya dengan koding sperti
berikut
package sandy.android.radio;
import android.app.Activity;
import android.os.Bundle;
import java.io.IOException;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
public class MainActivity extends Activity implements OnClickListener {
private ProgressBar playSeekBar1, playSeekBar2, playSeekBar3, playSeekBar4, playSeekBar5;
private Button buttonPlay1, buttonPlay2, buttonPlay3, buttonPlay4, buttonPlay5;
private Button buttonStopPlay1, buttonStopPlay2, buttonStopPlay3, buttonStopPlay4, buttonStopPlay5;
private MediaPlayer player, player2, player3, player4, player5;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initializeUIElements();
initializeMediaPlayer();
}
private void initializeUIElements() {
playSeekBar1 = (ProgressBar) findViewById(R.id.progressBar1);
playSeekBar1.setMax(100);
playSeekBar1.setVisibility(View.INVISIBLE);
buttonPlay1 = (Button) findViewById(R.id.buttonPlay1);
buttonPlay1.setOnClickListener(this);
buttonStopPlay1 = (Button) findViewById(R.id.buttonStopPlay1);
buttonStopPlay1.setEnabled(false);
buttonStopPlay1.setOnClickListener(this);
playSeekBar2 = (ProgressBar) findViewById(R.id.progressBar2);
playSeekBar2.setMax(100);
playSeekBar2.setVisibility(View.INVISIBLE);
buttonPlay2 = (Button) findViewById(R.id.buttonPlay2);
buttonPlay2.setOnClickListener(this);
buttonStopPlay2 = (Button) findViewById(R.id.buttonStopPlay2);
buttonStopPlay2.setEnabled(false);
buttonStopPlay2.setOnClickListener(this);
playSeekBar3 = (ProgressBar) findViewById(R.id.progressBar3);
playSeekBar3.setMax(100);
playSeekBar3.setVisibility(View.INVISIBLE);
buttonPlay3 = (Button) findViewById(R.id.buttonPlay3);
buttonPlay3.setOnClickListener(this);
buttonStopPlay3 = (Button) findViewById(R.id.buttonStopPlay3);
buttonStopPlay3.setEnabled(false);
buttonStopPlay3.setOnClickListener(this);
playSeekBar4 = (ProgressBar) findViewById(R.id.progressBar4);
playSeekBar4.setMax(100);
playSeekBar4.setVisibility(View.INVISIBLE);
buttonPlay4 = (Button) findViewById(R.id.buttonPlay4);
buttonPlay4.setOnClickListener(this);
buttonStopPlay4 = (Button) findViewById(R.id.buttonStopPlay4);
buttonStopPlay4.setEnabled(false);
buttonStopPlay4.setOnClickListener(this);
playSeekBar5 = (ProgressBar) findViewById(R.id.progressBar5);
playSeekBar5.setMax(100);
playSeekBar5.setVisibility(View.INVISIBLE);
buttonPlay5 = (Button) findViewById(R.id.buttonPlay5);
buttonPlay5.setOnClickListener(this);
buttonStopPlay5 = (Button) findViewById(R.id.buttonStopPlay5);
buttonStopPlay5.setEnabled(false);
buttonStopPlay5.setOnClickListener(this);
}
public void onClick(View v) {
if (v == buttonPlay1) {
startPlaying();
} else if (v == buttonStopPlay1) {
stopPlaying();
}
if (v == buttonPlay2) {
startPlaying2();
} else if (v == buttonStopPlay2) {
stopPlaying2();
}
if (v == buttonPlay3) {
startPlaying3();
} else if (v == buttonStopPlay3) {
stopPlaying3();
}
if (v == buttonPlay4) {
startPlaying4();
} else if (v == buttonStopPlay4) {
stopPlaying4();
}
if (v == buttonPlay5) {
startPlaying5();
} else if (v == buttonStopPlay5) {
stopPlaying5();
}
}
private void startPlaying() {
buttonStopPlay1.setEnabled(true);
buttonPlay1.setEnabled(false);
playSeekBar1.setVisibility(View.VISIBLE);
player.prepareAsync();
player.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
player.start();
}
});
}
private void startPlaying2() {
buttonStopPlay2.setEnabled(true);
buttonPlay2.setEnabled(false);
playSeekBar2.setVisibility(View.VISIBLE);
player2.prepareAsync();
player2.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
player2.start();
}
});
}
private void startPlaying3() {
buttonStopPlay3.setEnabled(true);
buttonPlay3.setEnabled(false);
playSeekBar3.setVisibility(View.VISIBLE);
player3.prepareAsync();
player3.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
player3.start();
}
});
}
private void startPlaying4() {
buttonStopPlay4.setEnabled(true);
buttonPlay4.setEnabled(false);
playSeekBar4.setVisibility(View.VISIBLE);
player4.prepareAsync();
player4.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
player4.start();
}
});
}
private void startPlaying5() {
buttonStopPlay5.setEnabled(true);
buttonPlay5.setEnabled(false);
playSeekBar5.setVisibility(View.VISIBLE);
player5.prepareAsync();
player5.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
player5.start();
}
});
}
private void stopPlaying() {
if (player.isPlaying()) {
player.stop();
player.release();
initializeMediaPlayer();
}
buttonPlay1.setEnabled(true);
buttonStopPlay1.setEnabled(false);
playSeekBar1.setVisibility(View.INVISIBLE);
}
private void stopPlaying2() {
if (player2.isPlaying()) {
player2.stop();
player2.release();
initializeMediaPlayer();
}
buttonPlay2.setEnabled(true);
buttonStopPlay2.setEnabled(false);
playSeekBar2.setVisibility(View.INVISIBLE);
}
private void stopPlaying3() {
if (player3.isPlaying()) {
player3.stop();
player3.release();
initializeMediaPlayer();
}
buttonPlay3.setEnabled(true);
buttonStopPlay3.setEnabled(false);
playSeekBar3.setVisibility(View.INVISIBLE);
}
private void stopPlaying4() {
if (player4.isPlaying()) {
player4.stop();
player4.release();
initializeMediaPlayer();
}
buttonPlay4.setEnabled(true);
buttonStopPlay4.setEnabled(false);
playSeekBar4.setVisibility(View.INVISIBLE);
}
private void stopPlaying5() {
if (player5.isPlaying()) {
player5.stop();
player5.release();
initializeMediaPlayer();
}
buttonPlay5.setEnabled(true);
buttonStopPlay5.setEnabled(false);
playSeekBar5.setVisibility(View.INVISIBLE);
}
private void initializeMediaPlayer() {
player = new MediaPlayer();
try {
player.setDataSource("http://live.radiorodja.com/");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar1.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
player2 = new MediaPlayer();
try {
player2.setDataSource("http://83.137.145.141:14240");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player2.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar2.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
player3 = new MediaPlayer();
try {
player3.setDataSource("http://usa8-vn.mixstream.net:8138");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player3.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar3.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
player4 = new MediaPlayer();
try {
player4.setDataSource("http://live.indostreamserver.com:8800/mustang");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player4.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar4.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
player5 = new MediaPlayer();
try {
player5.setDataSource("http://stream.suararadio.com:8000/rasikasemarang_mono");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player5.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar5.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
}
@Override
protected void onPause() {
super.onPause();
if (player.isPlaying()) {
player.stop();
}
if (player2.isPlaying()) {
player2.stop();
}
if (player3.isPlaying()) {
player3.stop();
}
if (player4.isPlaying()) {
player4.stop();
}
if (player5.isPlaying()) {
player5.stop();
}
}
}
4. setelay itu huaka res > layout > main.xmlnya isikan koding spt dibawah ini
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sumber: (http://live.radiorodja.com/)"
android:gravity="center" />
<ProgressBar
android:id="@+id/progressBar1"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="20dip"
android:maxHeight="20dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip">
</ProgressBar>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<Button
android:text="Play"
android:id="@+id/buttonPlay1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:text="Stop"
android:id="@+id/buttonStopPlay1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sumber: (Nautic Radio)"
android:gravity="center" />
<ProgressBar
android:id="@+id/progressBar2"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="20dip"
android:maxHeight="20dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip">
</ProgressBar>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<Button
android:text="Play"
android:id="@+id/buttonPlay2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:text="Stop"
android:id="@+id/buttonStopPlay2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sumber: (http://usa8-vn.mixstream.net:8138)"
android:gravity="center" />
<ProgressBar
android:id="@+id/progressBar3"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="20dip"
android:maxHeight="20dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip">
</ProgressBar>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<Button
android:text="Play"
android:id="@+id/buttonPlay3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:text="Stop"
android:id="@+id/buttonStopPlay3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sumber: (Mustang)"
android:gravity="center" />
<ProgressBar
android:id="@+id/progressBar4"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="20dip"
android:maxHeight="20dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip">
</ProgressBar>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<Button
android:text="Play"
android:id="@+id/buttonPlay4"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:text="Stop"
android:id="@+id/buttonStopPlay4"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Sumber: (Rasika Semarang)"
android:gravity="center" />
<ProgressBar
android:id="@+id/progressBar5"
android:indeterminateOnly="false"
android:progressDrawable="@android:drawable/progress_horizontal"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="20dip"
android:maxHeight="20dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip">
</ProgressBar>
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center">
<Button
android:text="Play"
android:id="@+id/buttonPlay5"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button
android:text="Stop"
android:id="@+id/buttonStopPlay5"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
</LinearLayout>
5. lalu isikan manifastnya spt dibawah ini
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sandy.android.radio"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:icon="@drawable/asd" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>





Gambling in the U.S. | CDC
BalasHapusIn this guide, you will look at the 영주 출장샵 gambling laws in a few 인천광역 출장마사지 different states — 서울특별 출장안마 Michigan, Mississippi, New 창원 출장마사지 Jersey, Illinois, Iowa, 포천 출장안마 Pennsylvania,