Is there any 3rd-party library in Android or Java that can play radio live stream?
File extension: .asx
MIME type: video/x-ms-asf
Unfortunately, MediaPlayer does not support this format!
Here is the url of the live stream: http:// 38.96.148.75 /SunnahAudio
EDIT:
I was able to convert .asf
file to .mp3
file by using JAVE:
File source = new File("sound.asf");
File target = new File("target.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(64000));
audio.setChannels(new Integer(1));
audio.setSamplingRate(new Integer(22050));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);
However, I'm streaming the .asf
online and I am not sure if I could stream the radio station, convert it to .mp3
, and immediately play it!
EDIT2:
I offer 500+ rep for anyone provides a full and working solution to play .asf
live stream on Android. Basically, I want to play this radio station on Android (as xiialive
can do):
http://38.96.148.75/SunnahAudio
If you open url of the stream in VLC player you can find out that it is an MMS
stream using WMA
codec mmsh://38.96.148.75/SunnahAudio?MSWMExt=.asf
Here is an open source project aacplayer-android which uses libmms
and libffmpeg
to
get WMA content from mms://
stream and play it.
I hope it solves your problem.
I was able to successfully play your stream on Android using Vitamio library. The biggest advantage of this lib is that it's API-compatible with Android SDK, so you'll just have to change imports in your code.
One of Vitamino plugins should be present on given device to use the library. Simply open Vitamio Demo in Eclipse
and take a look at how to use it. Prompting user to install Vitamio plugin is included in demo.
I was able to play your stream with this code:
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.os.Bundle;
public class VideoViewDemo extends Activity {
private String path = "mmsh://38.96.148.75/SunnahAudio";
private VideoView mVideoView;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
As you can see - similar to using VideoView
from Android SDK. Pretty much the only difference are imports.
The only difference to be noted is that I was unable to use http link, so I had to use the real streaming URL with mmsh protocol (opened in VLC - similar to what @vasart did).
For reference you can take a look at logs from successful playback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With