Android:从URL查看视频流

问题描述 投票:0回答:1

我正在尝试制作一个应用程序,该应用程序从基于微控制器的远程摄像机传输视频。它连接到控制器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>
java android stream iot
1个回答
0
投票

尝试使用ExoPlayer。及其来源:https://exoplayer.dev/media-sources.html

© www.soinside.com 2019 - 2024. All rights reserved.