小编Str*_*epk的帖子

检测设备是否为平板电脑

如何检测设备是否是平板电脑?下面的这个脚本不能正常工作。

var ua = navigator.userAgent, tablet = /Tablet|iPad/i.test(ua);
alert("Tablet? " + tablet);
Run Code Online (Sandbox Code Playgroud)

我不想检查是否是移动设备并使用else来显示平板电脑。我只想要一个功能来确认是否是平板电脑。我怎样才能做到这一点?谢谢

javascript

2
推荐指数
1
解决办法
2万
查看次数

播放时Android webview黑屏

我正在开发一个使用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
我已经做了什么:

  • 设置硬件加速=真
  • 设置 wv.setWebChromeClient(new WebChromeClient());
    并且视频屏幕保持黑色,仅运行音频。我该怎么办??

android html5-video html5-audio android-studio

0
推荐指数
1
解决办法
4843
查看次数