我正在尝试开发一个基于 Android 的应用程序,它可以从实时流中播放视频。这个直播流是使用Wowza Media Server制作的。
网址是:
rtsp://tv.hindiworldtv.com:1935/live/getpun
我在 ecliplse 中尝试了以下代码:
package com.kalloh.wpa;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.widget.MediaController;
import android.widget.VideoView;
public class a extends Activity {
VideoView videoView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//Create a VideoView widget in the layout file
//use setContentView method to set content of the activity to the layout file which contains videoView
this.setContentView(R.layout.videoplayer);
videoView = (VideoView)this.findViewById(R.id.videoView);
//add controls to a MediaPlayer like play, pause.
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
//Set the path of Video or URI
videoView.setVideoURI(Uri.parse("rtsp://tv.hindiworldtv.com:1935/live/getpnj"));
//
//Set the focus
videoView.requestFocus();
}
}
起初,它不起作用。
现在它开始工作,但在 20 到 30 秒后停止。我该如何解决这个问题?