我找到了应用程序代码,它(理论上)接收视频流并显示在 VideoView 对象上。
package com.example.cameraapp;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.MediaController;
import android.widget.VideoView;
import android.support.v4.app.NavUtils;
public class Camera extends Activity {
public VideoView mVideoView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
String LINK = "192.168.1.102:9889";
setContentView(R.layout.activity_camera);
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_camera, menu);
return true;
}
}
但是,当我运行 VLC 播放器 -> 流 -> Http 端口 9889 -> 转码 MPEG-2 NO SOUND 出现语句“不幸的是,无法显示此视频文件”。我尝试了 rtsp,转码 H.264,但没有帮助。有谁知道为什么它不起作用?