【发布时间】:2020-03-03 18:59:04
【问题描述】:
我正在尝试制作一个应用,该应用可以从基于微控制器的远程摄像头流式传输视频。它连接到控制器softAP。控制器的基本地址 (192.168.4.1:80) 是来自其摄像头的视频流。我想在应用程序中显示它。
我尝试过 WebView,但它不起作用。出现 DNS 配置问题。现在我尝试用 VideoView 来做,但它只显示黑屏。 我怎么能打开它,没有任何控制按钮。只是普通的流。
我的代码:
public class WebViewActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
VideoView main = new VideoView(this);
Uri url = Uri.parse("192.168.4.1:80");
main.setVideoURI(url);
main.start();
}
}
xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WebViewActivity">
<VideoView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
【问题讨论】: