标题翻译
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("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>
答案1
得分: 0
尝试使用ExoPlayer。
以及其资源:https://exoplayer.dev/media-sources.html。
英文翻译
Try ExoPlayer.
And its sources: https://exoplayer.dev/media-sources.html
专注分享java语言的经验与见解,让所有开发者获益!
评论