现场音频流媒体与Android 2.X [英] Live audio streaming with Android 2.x
问题描述
我要与2.x和更高版本的设备上播放实时流。 这的说,它是不可能发挥实时流上的设备与Android 2。的X.
I need to play a live stream on devices with 2.x and greater versions. This states that it's impossible to play live streams on devices with Android 2.x.
我算什么选择这里?尤其是我感兴趣的流式音频 - ?我应该选择什么形式和与此相关的协议
What're my options here ? Especially I'm interested in streaming audio - what format should i pick and in conjunction with which protocol ?
P.S。我试过Vitamio - 不想让客户下载的第三方库
P.S. I've tried Vitamio - don't want to make customers download third party libraries.
UPD
- 为什么我可以玩这个流http://188.138.112.71:9018/?
推荐答案
尝试这个例子的RTSP流(网址应支持RTSP)视频改变code,支持刚音频
try this example for RTSP streaming (the url should support RTSP) for video change the code to support just audio
public class MultimediaActivity extends Activity {
private static final String RTSP = "rtsp://url here";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.multimedia);
//***VideoView to video element inside Multimedia.xml file
VideoView videoView = (VideoView) findViewById(R.id.video);
Log.v("Video", "***Video to Play:: " + RTSP);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
Uri video = Uri.parse(RTSP);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();
}
}
编辑:
现场音频流在Android中使用的MediaPlayer 现场音频流在Android中,从1.6 SDK开始被变得如此容易。在的setDataSource()API直接通过网址和音频将发挥没有任何问题。
Live Audio streaming using MediaPlayer in Android Live Audio streaming in android, from 1.6 sdk onwards is become so easy. In setDataSource() API directly pass the url and audio will play without any issues.
完整的code段是,
public class AudioStream extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url = "http://www.songblasts.com/songs/hindi/t/three-idiots/01-Aal_Izz_Well-(SongsBlasts.Com).mp3";
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(url);
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.prepare();
mp.start();
} catch (Exception e) {
Log.i("Exception", "Exception in streaming mediaplayer e = " + e);
}
}
}
这篇关于现场音频流媒体与Android 2.X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!