Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: beginner developing android app to stream radio station needs help!

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Thanked 1 Time in 1 Post

    Cool beginner developing android app to stream radio station needs help!

    Good evening everyone!

    I am new to this Java thing, but I have learned so much over the past few weeks, and I feel like I'm really starting to get a hang of it. I am currently developing my first project, an android app for a small radio network which will allow you to stream the station live. To make this happen, I must query a .pls stream file, and extract the three possible URLs for the listen link. I cannot directly link to any of the URLs because they are dynamic and can change without warning. Before implementing this part of the code, I was able to easily make a direct link to one of those streams and get audio playing. Yay me. Anyways, I have a class set up, PlsParse, which connects, opens and parses the pls file, extracts the three links, and returns them to be open with MediaPlayer. This is when everything goes awry. There are no compile errors and it runs, it just crashes when I access the listen live page. Thanks for any help you may bring, and I promise to one day return the favor to a newbie and help them in their time of need. Much obliged and good night. Here is the code:

    package com.comedy.app;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.LinkedList;
    import java.util.List;
    import com.comedy.app.ListenToStream.PlsParser;
    import android.app.Activity;
    import android.media.AudioManager;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.widget.ImageView;
    import android.widget.RatingBar;
    import android.widget.TextView;
    public class ListenToStream extends Activity {
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		TextView artistName = (TextView) findViewById(R.id.txtArtistName);
    		TextView albumName = (TextView) findViewById(R.id.txtAlbumName);
    		RatingBar starRating = (RatingBar) findViewById(R.id.ratingBar1);
    		ImageView albumPicture = (ImageView) findViewById(R.id.albumImage);
    		MediaPlayer comedyStream = new MediaPlayer();
    		String urlToStream = null;
    		try {
    			urlToStream = new PlsParser(
    		} catch (IOException e1) {
    			// TODO Auto-generated catch block
    		try {
    			comedyStream.prepare(); // might take long! (for buffering, etc)
    		} catch (IllegalArgumentException e) {
    			// TODO Auto-generated catch block
    		} catch (SecurityException e) {
    			// TODO Auto-generated catch block
    		} catch (IllegalStateException e) {
    			// TODO Auto-generated catch block
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    	public class PlsParser {
    		private final BufferedReader reader;
    		public PlsParser(String url) throws IOException, IOException {
    			URLConnection urlConnection = new URL(url).openConnection();
    			this.reader = new BufferedReader(new InputStreamReader(
    		public List<String> getUrls() {
    			LinkedList<String> urls = new LinkedList<String>();
    			while (true) {
    				try {
    					String line = reader.readLine();
    					if (line == null) {
    					String url = parseLine(line);
    					if (url != null && !url.equals("")) {
    				} catch (IOException e) {
    			return urls;
    		private String parseLine(String line) {
    			if (line == null) {
    				return null;
    			String trimmed = line.trim();
    			if (trimmed.indexOf("http") >= 0) {
    				return trimmed.substring(trimmed.indexOf("http"));
    			return "";
    Last edited by infiniteoo; February 2nd, 2012 at 23:10.

  2. The Following User Says Thank You to infiniteoo For This Useful Post:

    urircuche (February 24th, 2014)

  3. #2
    Junior Member
    Join Date
    Jan 2012
    Thanked 3 Times in 3 Posts

    Default Re: beginner developing android app to stream radio station needs help!

    Okay so I'm relatively new to Android myself, but what I would do is put print statements or breaks at various parts of your code to figure out where it crashed. A good place to start would be after your first try catch statement

  4. The Following User Says Thank You to marylandfour For This Useful Post:

    urircuche (February 24th, 2014)

Similar Threads

  1. Best Tools for developing in Java/Android
    By Nesh108 in forum Android Development
    Replies: 10
    Last Post: September 11th, 2012, 10:01
  2. Any alternative of Eclipse for developing android app?
    By vincentroberts in forum Java IDEs
    Replies: 6
    Last Post: January 5th, 2012, 00:48
  3. Quick beginner radio button question
    By smarmy_cheauffeur in forum AWT / Java Swing
    Replies: 2
    Last Post: October 17th, 2011, 08:20
  4. could not create audio stream from input stream
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: June 2nd, 2011, 02:08
  5. How to develop plugins in Netbeans?
    By haygaurav in forum Web Frameworks
    Replies: 1
    Last Post: May 27th, 2009, 16:49

Tags for this Thread