Android:从URL查看视频流

huangapple 未分类评论64阅读模式
标题翻译

Android: Viewing video stream from url

问题

以下是您要翻译的内容:

我正在尝试制作一个应用程序,从基于微控制器的远程摄像头中进行视频流传输。它连接到控制器的软AP。在控制器的基本地址(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>
英文翻译

I'm trying to make an app, that streams video from remote camera built on microcontroller. It connects to controllers softAP. On basic adress of controller (192.168.4.1:80) is video stream from its camera. I would like to show it in app.

I've tried WebView, but it don't work. DNS config problem appears. Now I try to do it with VideoView, but it only shows black screen.
How can I open it, without any control buttons. Just plain stream.

My code:

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(&quot;192.168.4.1:80&quot;);
        main.setVideoURI(url);
        main.start();
    }
}

xml:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    tools:context=&quot;.WebViewActivity&quot;&gt;

    &lt;VideoView
        android:id=&quot;@+id/webview&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot; /&gt;

&lt;/RelativeLayout&gt;

答案1

得分: 0

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

英文翻译

Try ExoPlayer.
And its sources: https://exoplayer.dev/media-sources.html

huangapple
  • 本文由 发表于 2020年3月4日 02:59:04
  • 转载请务必保留本文链接:https://java.coder-hub.com/60513883.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定