Streaming Live Audio

All your problems with Audio, Video and Images.

Streaming Live Audio

Postby nrana » Tue Aug 31, 2010 8:16 pm

Hi,

I am new to android and Trying to make live audio streaming application. I am using below code for the same. I tried playing mp3 as shown in the urlpath variable which works fine but when i try live radio it does not work as you can see the link is commented out. Do I need actual phone to test it or am I doing something wrong??

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package funasia.radio.net;
  2.  
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.FileNotFoundException;
  6. import java.io.IOException;
  7. import java.security.InvalidParameterException;
  8.  
  9. import android.app.Activity;
  10. import android.media.AudioFormat;
  11. import android.media.AudioManager;
  12. import android.media.MediaPlayer;
  13. import android.media.AudioTrack;
  14. import android.os.Bundle;
  15. import android.view.View;
  16. import android.view.View.OnClickListener;
  17. import android.widget.Button;
  18.  
  19.  
  20.  
  21. public class funasia extends Activity {
  22.     /** Called when the activity is first created. */
  23.        
  24.         public String urlpath="http://www.pocketjourney.com/downloads/pj/tutorials/audio.mp3";
  25.         //public String urlpath= "http://www.funasia.net/radio/radiosuno.asx";
  26.        
  27.     @Override
  28.     public void onCreate(Bundle savedInstanceState) {
  29.         super.onCreate(savedInstanceState);        
  30.         setContentView(R.layout.main);
  31.        
  32.         Button btnStream = (Button)findViewById(R.id.btnStream);
  33.         btnStream.setOnClickListener(new OnClickListener() {           
  34.         //      @Override
  35.                 public void onClick(View v){
  36.                         PlayAudio();
  37.                 }
  38.         });
  39.        
  40.     }
  41.    
  42.  
  43.     private void PlayAudio()
  44.     {
  45.         MediaPlayer mp = new MediaPlayer();
  46.         try {
  47.                         mp.setDataSource(urlpath);
  48.                 } catch (IllegalArgumentException e) {
  49.                         // TODO Auto-generated catch block
  50.                         e.printStackTrace();
  51.                 } catch (IllegalStateException e) {
  52.                         // TODO Auto-generated catch block
  53.                         e.printStackTrace();
  54.                 } catch (IOException e) {
  55.                         // TODO Auto-generated catch block
  56.                         e.printStackTrace();
  57.                 }
  58.         try {
  59.                         mp.prepare();
  60.                 } catch (IllegalStateException e) {
  61.                         // TODO Auto-generated catch block
  62.                         e.printStackTrace();
  63.                 } catch (IOException e) {
  64.                         // TODO Auto-generated catch block
  65.                         e.printStackTrace();
  66.                 }
  67.                
  68.         mp.start();
  69.        
  70.     }
  71.        
  72.    
  73. }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


Any suggestion

Thanks in advance
nrana
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Aug 25, 2010 9:17 pm

Top

Re: Streaming Live Audio

Postby gvenugopal141 » Mon Nov 08, 2010 8:02 pm

Hi nrana,
I am also facing the same issue in my app. If you get the solution, please tell me at gvenugopal141@gmail.com
gvenugopal141
Freshman
Freshman
 
Posts: 3
Joined: Wed Oct 13, 2010 3:52 pm

Re: Streaming Live Audio

Postby fbarnard » Tue Nov 09, 2010 8:54 am

hi

can it maybe be the format here is formats android supports

http://developer.android.com/guide/appe ... rmats.html
fbarnard
Developer
Developer
 
Posts: 44
Joined: Tue Jun 15, 2010 12:31 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 18 guests