我試圖開發電視流(HLS)的應用程序。使用下面的代碼我測試了2.3.3,3.0和4.0.1版Android設備上的流,但遇到了幾個問題。 在Android 2.3.3上,播放時間大於1分鐘,然後停止播放。在Android 3.0上播放良好,在Android 4.0.3上顯示消息'This file can not be playing'(如果我沒有記錯的話)。 所以我的問題是: 如何在這些設備的ether上播放流,而不會產生流播放問題?或者我可以在哪裏閱讀更多關於這些問題的解決方案(嘗試搜索,但沒有發現任何用處)?Android VideoView直播電視流(HLS)
守則Main_Activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView player = (VideoView)findViewById(R.id.player);
String httpLiveUrl = "http://aj.lsops.net/live/aljazeer_en_high.sdp/playlist.m3u8";
//for Android 2.3.3 I used httplive:// prefix
player.setVideoURI(Uri.parse(httpLiveUrl));
player.setMediaController(new MediaController(this));
player.requestFocus();
player.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
代碼中的XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:id="@+id/player"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
</RelativeLayout>
很抱歉,如果我的英語很差。 謝謝。
請分享您如何播放直播印地語頻道? –