【发布时间】:2018-05-02 04:26:26
【问题描述】:
我正在开发一个使用 WebView 加载外部视频 (.mp4) 的应用,但页面只播放音频,并且视频只是“黑色”。我已经搜索了很多,并做了所有可能的事情来尝试解决这个问题,但我失败了。你能帮帮我吗?
MainActivity.java
-- REMOVED --
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="topflix.topflix">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/rounded"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:hardwareAccelerated="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="topflix.topflix.MainActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/wv"
/>
</android.support.constraint.ConstraintLayout>
activity_main.xml的打印>点击here
视频网址:http://media-br-am.crackle.com/1/3/v6/11zlf_480p.mp4
测试网站:ntcdn.stream/prop/httpdelivery/modal
我已经做了什么:
- 设置 hardwareAccelerated=true
- 设置 wv.setWebChromeClient(new WebChromeClient());
并且视频屏幕持续为黑色,仅运行音频。我该怎么办??
【问题讨论】:
-
发布您尝试在 webview 中加载的视频网址
-
线程更新了!谢谢
-
在下面查看我的答案
-
并非所有视频格式都受支持。可能您的视频格式不受支持。(至少在您的设备上)
-
不敢相信我的 J5 无法加载 .mp4 视频:\
标签: android android-studio html5-video html5-audio