0

我遇到了一个问题 Video mp4 url​​ work in WebView 但我把 VideoView 放在里面不工作的 url 消息弹出窗口“对不起,这个 url 不工作”。我不知道的确切问题是什么?您知道这种解决方案,请帮助我。并分享您的精彩体验。谢谢你!

4

2 回答 2

1

它与您的链接和内容有关。尝试以下两个链接: String path="http://www.ted.com/talks/download/video/8584/talk/761"; 字符串路径1="http://commonsware.com/misc/test2.3gp";

Uri uri=Uri.parse(path1);

VideoView video=(VideoView)findViewById(R.id.VideoView01);
video.setVideoURI(uri);
video.start();

从“path1”开始,它是一个轻量级的小视频流,然后尝试“path”,它比“path1”分辨率更高,完美的手机分辨率。

于 2019-07-10T08:30:22.953 回答
0

看起来只有安全的 URL 有效(developers.google.com/training/images/tacoma_narrows.mp4使用 HTTPS 时"kuiber.com/images/stories/1557736976-9002.mp4使用 HTTP)

根据文档

从 Android 9(API 级别 28)开始,明文支持默认禁用。

因此,您必须将属性设置android:usesCleartextTraffictrue

android:usesCleartextTraffic

指示应用程序是否打算使用明文网络流量,例如明文 HTTP。面向 API 级别 27 或更低级别的应用的默认值为“true”。以 API 级别 28 或更高级别为目标的应用默认为“false”。

要解决此问题,请android:usesCleartextTraffic="true"application tag清单中使用

<application
     ...
     android:usesCleartextTraffic="true"
     ...>
     ...
</application>
于 2019-07-10T08:52:47.390 回答