【发布时间】:2012-07-01 18:13:48
【问题描述】:
我正在尝试开发一个基于 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 秒后停止。我该如何解决这个问题?
【问题讨论】:
-
我在使用 vlc 时遇到了同样的问题,并在这里找到了一些东西(这不是解决方案,而是有用的信息):code.google.com/p/android/issues/detail?id=15229
-
现在给定的 url 可以在 Android 4 及更高版本上运行。但问题仍然是音频不连续。播放 2 秒后会延迟 1 秒。
-
你是如何解决这个问题的?
-
您的代码无需任何更改即可在 Nexus7 上运行..
-
我在 Nexus10 上尝试了 android 版本 4.4.4,它给出了
Can't play this video异常。
标签: android streaming live rtsp wowza