Netflix in Android WebView

别说谁变了你拦得住时间么 提交于 2021-02-18 19:12:28

问题


So let me preface this by saying downloading the Netflix App is not an option. So my thought is to just make a wrapper app that loads the netflix website in a WebView. This works for login/navigation; however, whenever you hit the play button to start playing the video, there is no response and no output in logcat. I'm looking for a way to see more debug messages from the WebView or a way to get the video playing. Using Android 4.4.4 by the way.

View layout = LayoutInflater.from(mActivity).inflate(R.layout.main_layout, vContentAreaContainer, false);

WebView webView = (WebView) layout.findViewById(R.id.main_web_view);
            webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setDomStorageEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());

webView.loadUrl("http://www.netflix.com");
vContentAreaContainer.addView(layout);

回答1:


You can load Netflix in Android Webview but wont be able to play Netflix videos because:

  • if user agent is mobile device than Netflix will use intent based url schema. This intents are handled by Netflix app and if device dont have Netflix installed to handle them then "install Netflix screen" will be shown.

  • If you manually set user agent to desktop then Netflix will ask to install Microsoft Silverlight Plugin which is available only for Mac and Windows. So again you will reach a dead end.

         webView.setScrollbarFadingEnabled(false)
    
         val newUA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12) 
             AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50"
    
        webView.getSettings().setUserAgentString(newUA)
    


来源:https://stackoverflow.com/questions/35285671/netflix-in-android-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!