我正在尝试播放实时RTSP视频(来自rtsp:// IP_ADDR:554 / user = admin& password = admin& channel =& stream = .sdp?real_stream - rtp-caching = 100) android VideoView,这是我的代码:
public class TestCamera3 extends Activity {
private VideoView mVideoView;
private String videoAddress;
private static final String TAG = "videoTest";
private String keyValue = "videoAddress";
private String defaultAddress = "rtsp://IP_ADDR:554/user=admin&password=admin&channel=&stream=.sdp?real_stream--rtp-caching=100";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
SharedPreferences prefs = this.getSharedPreferences(TAG, 0);
videoAddress = prefs.getString(keyValue, defaultAddress);
mVideoView = (VideoView) findViewById(R.id.video);
PlayRtspStream(defaultAddress);
}
private void PlayRtspStream(String rtspUrl) {
// mVideoView.setVideoPath(rtspUrl);
mVideoView.setVideoURI(Uri.parse(rtspUrl));
mVideoView.requestFocus();
mVideoView.setMediaController(new MediaController(this));
mVideoView.start();
}}
&安培; activity_main.xml:
<LinearLayout 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/video"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</VideoView>
所以,当我在Samsung Note 4 v4.2.2(Jelly Bean)&amp ;; Nexus 5 v5.0(Lollipop)..它运行良好但是当我在Galaxy tab 3 v4.1.2(Jelly Bean)中测试它时显示消息(无法播放此视频)
任何人都可以告诉我为什么会这样吗?