WebView - Youtube videos playing in background on rotation and minimise

后端 未结 2 1799
南旧
南旧 2021-02-10 16:08

I have an issue with WebView, basically I am loading in a forum that has embedded videos in places, if you play a video then rotate the device the video keeps playing in the bac

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-10 17:06

    When minimizing the app, you need to pause your webview. Use this code to pause your webview

    Class.forName("android.webkit.WebView")
                            .getMethod("onPause", (Class[]) null)
                            .invoke(webview, (Object[]) null);
    

    And about "Video plays even you rotate your phone", this is the functionality not a bug !

提交回复
热议问题