Question: I have a url: `"http://my_server/song.mp3"`

My code: 

```
String url_song="http://my_server/song.mp3";
MediaPlayer mMediaPlayer=new MediaPlayer();
mMediaPlayer.setDataSource(url_song);
mMediaPlayer.prepare();
mMediaPlayer.start();

```

But it have error (100 0), can not play, i try to download this file and play it in local, it's ok.
So, MediaPlayer have error when play online?

Can someone help me?

Thank all!

Answer: 
Network traffic can never be in the UI thread in Android. Use an `AsyncTask`.

```
new AsyncTask<Void,Void,Void>(){
    public Void doInBackground(Void... v) {
        String url_song="http://my_server/song.mp3";
        MediaPlayer mMediaPlayer=new MediaPlayer();
        mMediaPlayer.setDataSource(url_song);
        mMediaPlayer.prepare();
        mMediaPlayer.start();
    }
}.execute();

```

Also, make sure you have the Internet permission in your manifest.
use the Intent.ACTION\_VEW

```
String url_song="http://my_server/song.mp3";
Intent intent = new Intent(Intent.ACTION_VIEW);                                                                          
intent.setDataAndType(Uri.parse(url_song), "audio/*");
startActivity(intent);

```

This would let the user select the third party app they want the remote mp3 to be played on. Similar to when you open up an image and a dialog shows up letting you select what app you want to use to open up the image.