Hi i have sent u the simple code needed for audio streaming.Check it.Its
working.
HaPpY CoDiNg :)
Regards,
Talha Qamar.
On Sat, Dec 22, 2012 at 11:05 AM, Ali <[email protected]> wrote:
> Hi All,
>
> We are looking to develop an Audio streaming application where we have the
> media files on a web server and have users browse them and play them on
> android phones. What is the best approach to develop this. Would be
> helpfule if you can share your experiences and best practices.
>
> Thanks for your time.
>
> Cheers,
> Ali
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
public class StreamaudioActivity extends Activity implements OnClickListener,
OnPreparedListener, OnErrorListener, OnCompletionListener {
MediaPlayer mp;
ProgressDialog pd;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
if(mp!= null){ mp.stop();}
else{
Button bt = (Button)findViewById(R.id.play);
bt.setOnClickListener(this);
}
}
public void onCompletion(MediaPlayer arg0) {
pd.dismiss();
Toast.makeText(getApplicationContext(), "Completed",
Toast.LENGTH_LONG).show();
// mp.start();
}
public boolean onError(MediaPlayer mp, int what, int extra) {
pd.dismiss();
return false;
}
public void onPrepared(MediaPlayer mp) {
Log.i("StreamAudioDemo", "finished");
pd.setMessage("Playing.....");
mp.start();
}
public void onClick(View arg0) {
try
{
pd = new ProgressDialog(this);
pd.setMessage("Buffering.....");
pd.show();
mp = new MediaPlayer();
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.setOnPreparedListener(this);
mp.setOnErrorListener(this);
mp.setDataSource("http://www.robtowns.com/music/blind_willie.mp3");
mp.prepareAsync();
mp.setOnCompletionListener(this);
}
catch(Exception e)
{
Log.e("StreamAudioDemo", e.getMessage());
}
}
}