in my app many sounds . its run by Internet by url >>
I want to set progress Bar in my app ?
How I do it ?
this is sound Activity:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical"
tools:ignore="ScrollViewSize" >
<MediaController
android:id="@+id/mediaController1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="66dp"
android:layout_marginRight="14dp" >
</MediaController>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/play"
android:layout_centerHorizontal="true"
tools:ignore="NotSibling" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="316dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:paddingBottom="90dp"
android:paddingTop="50dp"
android:src="@drawable/logo5"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_action_play"
tools:ignore="ContentDescription,ObsoleteLayoutParam" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:text="@string/song1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="@+id/dawnload"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/play"
android:src="@drawable/ic_action_download"
tools:ignore="ContentDescription,ObsoleteLayoutParam" />
<ImageButton
android:id="@+id/sahere"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/play"
android:src="@drawable/ic_action_share"
tools:ignore="ContentDescription,ObsoleteLayoutParam" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
also this is sound class
package com.Helmi_wa_ana;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class Sound1 extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sound1);
final MediaPlayer mediaController1 = new MediaPlayer();
try {
mediaController1.setDataSource("http://alshbab90.softsmedia.com/helmi_1.mp3");
} catch (IllegalArgumentException e1) {
e1.printStackTrace();
} catch (IllegalStateException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
mediaController1.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
ImageButton play = (ImageButton) findViewById(R.id.play);
play.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (mediaController1.isPlaying()) {
mediaController1.pause();
} else {
mediaController1.start();
}
}
});
ImageButton sahere = (ImageButton) findViewById(R.id.sahere);
sahere.setOnClickListener(new OnClickListener() {
public void onClick(View v)
{
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getResources().getString(R.string.share1));
startActivity(Intent.createChooser(sharingIntent,"?????? ???????? ?????? :"));
}
});
ImageButton dawnolad = (ImageButton) findViewById(R.id.dawnload);
dawnolad.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
}
protected InputStream openUrl() {
String url = "http://alshbab90.softsmedia.com/helmi_1.mp3";
InputStream stream = null;
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection)new URL(url).openConnection();
} catch (MalformedURLException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
stream = connection.getInputStream();
}
} catch (IOException e) {
e.printStackTrace();
}
return stream;
}
});
}
}