[android-developers] Re: Playing a audio stream not working using MediaPlayer

2009-11-30 Thread Jens-Christian Larsen
Thank you Klaus for the response.
What you say is also what I have come to understand.
I think I will try to download a local copy of the streamed content
and play that instead.
In any case the MediaPlayer class seem not to be working correctly in
most streaming audio cases.
I guess I will have to look into making it a service too.

best regards
Jens-Christian

On 30 Nov., 11:57, Nugman klaus.nuta...@googlemail.com wrote:
 First of all the MediaPlayer does not support all music streaming
 formats, as I understood.
 I also struggeling with it.
 For me it is working to play a mp3 file located on a server. Try this
 first.
 But it seems that m3u or aac is not supported at all. (Implement a
 ErrorListener to see the error)
 I hope that I am wrong in this case, but I cant get it to work,
 either.
 Maybe you can decrypt the m3u file yourself to get the mpeg itself.
 Let me know how this works.

 Nevertheless the best thing is, to create a remote service (or a
 thread) that prepares and plays the music. So it does not disturb the
 main gui.

 Sorry that is all I know.
 Greets Klaus

 On 27 Nov., 11:25,Jens-ChristianLarsen jenschrlar...@gmail.com
 wrote:

  I am trying to make a very simple radio player for Android and I
  cannot get the audio streaming to work. In my latest attempt it plays
  for about 1 second and stops for some streams and it doesnt work at
  all for some other streams. Logcat doesn't give much useful
  information to me.
  I am testing on HTC Hero (Android 1.5).

  If I hook the completion and buffer events I see the audio gets a
  complete event but it keeps buffering.
  Is there anything wrong with the code below?
  Should I be able to stream the the audio streams below?
  Is there a complete example somewhere of a working radio streaming?

  Thanks for any and all suggestions.

  public class MyActivity extends Activity implements OnPreparedListener
  {
          MediaPlayer streamPlayer = new MediaPlayer();

          public void onPrepared(MediaPlayer mp) {
                  streamPlayer.start();
          }

          @Override
          public void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  String path = http://www.nch.com.au/acm/sample.aac;;
                  // String path = http://radio.bis.bg:8000/buddhabar;;
                  // String path = 
  http://kzsulive.stanford.edu/audio/kzsu-1-24.m3u;;
                  try {
                          Uri uri = Uri.parse(path);
                          streamPlayer.reset();
                          streamPlayer.setDataSource(this, uri);
                          
  streamPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
                          streamPlayer.setOnPreparedListener(this);
                          streamPlayer.prepareAsync();
                  } catch (Exception e) {
                          e.printStackTrace();
                  }
                  setContentView(R.layout.main);
          }

  }



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Playing a audio stream not working using MediaPlayer

2009-11-28 Thread Jens-Christian Larsen
I am trying to make a very simple radio player for Android and I
cannot get the audio streaming to work. In my latest attempt it plays
for about 1 second and stops for some streams and it doesnt work at
all for some other streams. Logcat doesn't give much useful
information to me.
I am testing on HTC Hero (Android 1.5).

If I hook the completion and buffer events I see the audio gets a
complete event but it keeps buffering.
Is there anything wrong with the code below?
Should I be able to stream the the audio streams below?
Is there a complete example somewhere of a working radio streaming?

Thanks for any and all suggestions.


public class MyActivity extends Activity implements OnPreparedListener
{
MediaPlayer streamPlayer = new MediaPlayer();

public void onPrepared(MediaPlayer mp) {
streamPlayer.start();
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String path = http://www.nch.com.au/acm/sample.aac;;
// String path = http://radio.bis.bg:8000/buddhabar;;
// String path = 
http://kzsulive.stanford.edu/audio/kzsu-1-24.m3u;;
try {
Uri uri = Uri.parse(path);
streamPlayer.reset();
streamPlayer.setDataSource(this, uri);

streamPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
streamPlayer.setOnPreparedListener(this);
streamPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
setContentView(R.layout.main);
}
}

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en