Java Android:从url查看视频流
我正在尝试制作一个应用程序,它可以从微控制器上构建的远程摄像机中传输视频。它连接到控制器softAP。控制器的基本地址(192.168.4.1:80)是来自其摄像机的视频流。我想在应用程序中显示它 我试过WebView,但不起作用。出现DNS配置问题。现在我试着用VideoView来做,但它只显示黑屏。 我如何打开它,没有任何控制按钮。只是一条小溪 我的代码:Java Android:从url查看视频流,java,android,stream,iot,Java,Android,Stream,Iot,我正在尝试制作一个应用程序,它可以从微控制器上构建的远程摄像机中传输视频。它连接到控制器softAP。控制器的基本地址(192.168.4.1:80)是来自其摄像机的视频流。我想在应用程序中显示它 我试过WebView,但不起作用。出现DNS配置问题。现在我试着用VideoView来做,但它只显示黑屏。 我如何打开它,没有任何控制按钮。只是一条小溪 我的代码: public class WebViewActivity extends AppCompatActivity { @Ove
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:
试试ExoPlayer。
它的来源:我不想使用外部库。ExoPlayer是谷歌最强大的库,它有很多有用的媒体流功能。建议用于媒体流。内容类型:image/jpeg,我在Exo中没有看到用于此的ant解决方案。您需要视频流。对于图像,请使用ImageView。或者,如果您想将图像和视频结合起来,请创建自己的自定义视图组,并为视图提供正确的可见性逻辑。
<?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>