如何检测设备是否仅是平板电脑?下面的这个脚本不能正常工作。
var ua = navigator.userAgent, tablet = /Tablet|iPad/i.test(ua);
alert("Tablet? " + tablet);
Run Code Online (Sandbox Code Playgroud)
我不想检查是否是移动设备并使用else来显示平板电脑。我只想要一个功能来确认是否是平板电脑。我怎样才能做到这一点?谢谢
我正在开发一个使用WebView加载外部视频 (.mp4)的应用程序,但该页面仅播放音频,而视频仅为“黑色”。我已经搜索了很多并做了所有可能的事情来尝试解决这个问题,但我失败了。你能帮助我吗?
主活动.java
-- REMOVED --
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
活动_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>
Run Code Online (Sandbox Code Playgroud)
打印 activity_main.xml > 点击这里
视频网址:http
://media-br-am.crackle.com/1/3/v6/11zlf_480p.mp4 测试网站:ntcdn.stream/prop/httpdelivery/modal
我已经做了什么: