WebView 在非全屏模式下随机播放直播流

问题描述

我正在编写一个只有全屏 webview 对象的应用程序,没有菜单、按钮、文本或任何其他对象,通过远程控制进行控制。

它只是在横向模式下再现全屏实时视频流,并且不会旋转。

我向 webview 提供直播网址!!.loadUrl,没有 html 页面或任何其他类型的网址。

对于某些视频源,视频不是立即全屏,而是在屏幕中央占据一个矩形,然后在几秒钟后切换到全屏(发生时间是随机的)

        override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        [..]

        window.setFlags(
            WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

        webview = findViewById(R.id.myweb)
        webview!!.webViewClient = WebViewClient()
        webview!!.settings.javaScriptEnabled = false
        webview!!.settings.domStorageEnabled = true
        webview!!.settings.builtInZoomControls = false     
        webview!!.settings.setSupportZoom(false)           
        webview!!.overScrollMode = WebView.OVER_SCROLL_NEVER
        webview!!.settings.useWideViewPort = true
        webview!!.setBackgroundColor(0)
        webview!!.setinitialScale(1)

        webview!!.loadUrl(ChannelList.getChannelUrl())

这是 content_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"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:showIn="@layout/activity_main"
        tools:context=".MainActivity">

    <WebView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/myweb"
            tools:layout_editor_absoluteY="8dp"
            tools:layout_editor_absoluteX="8dp"
            android:layout_alignParentRight="false"/>

</android.support.constraint.ConstraintLayout>

我在 content_main 和 webview 设置中尝试了许多不同的设置;没运气。 你知道发生了什么吗?

先谢谢你

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)