I am developing an application that should play Radio from Shout. For API, I followed this URL
I will be able to get the station identifier with my developer identifier. Now, in the "How to tune to a station" section, they were guided by tuning to a specific station. I followed this section and used this URL in my Android multimedia player. But my media player does not play anything.
Please note that my target SDK is 16 and the Min SDK is 13. Therefore, I hope the Android version is not a problem. The media player works great if you use other URLs, for example:
So, I think that there are no problems with my media player. I already went through the mail, which is available at SO. Please, help.
public class MainActivity extends Activity { Button play,pause,stop; private MediaPlayer mediaPlayer; private String out; // private String url = "http://yp.shoutcast.com/sbin/tunein-station.pls?id=175821"; // private String url = "http://www.hrupin.com/wp-content/uploads/mp3/testsong_20_sec.mp3"; private String url1 = "http://streamplus8.leonex.de:14910"; private String url2 ="http://s2.voscast.com:7016/"; private String url3 ="http://s8.voscast.com:7024/"; private String url4 ="http://s8.voscast.com:7020/"; private String url5 ="http://s5.voscast.com:8216/"; private boolean pauseState = false; ProgressDialog pd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); pd = new ProgressDialog(this); pd.setMessage("Loading your song...."); play = (Button)findViewById(R.id.btn_play); pause = (Button)findViewById(R.id.btn_pause); stop = (Button)findViewById(R.id.btn_stop); mediaPlayer = new MediaPlayer(); this.setVolumeControlStream(AudioManager.STREAM_MUSIC); try { mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setDataSource(url2); mediaPlayer.prepareAsync(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "Please check your connection!", Toast.LENGTH_LONG).show(); e.printStackTrace(); } play.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if(pauseState == true) { mediaPlayer.start(); } else { pd.show(); mediaPlayer.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mediaPlayer.start(); if(mediaPlayer.isPlaying()){ pd.dismiss(); } } }); } pauseState = false; } }); pause.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mediaPlayer.pause(); pauseState = true; } }); stop.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mediaPlayer.stop(); // mediaPlayer.release(); } }); } }
source share