2017-10-08 154 views
0

我有我的網站上,這是通過網頁視圖增加了一個視頻播放器,我可以看到我的視頻,但在選擇全屏按鈕的那一刻,它不的WebView視頻全屏

這是我的課Java中,一切都很好,但是當我試圖把全屏幕的按鈕,不做funtion,在我的版本的手機和網站,我可以沒有任何問題做

import android.content.Intent; 
    import android.net.Uri; 
    import android.support.v7.app.AppCompatActivity; 
    import android.os.Bundle; 
    import android.view.KeyEvent; 
    import android.webkit.WebSettings; 
    import android.webkit.WebView; 
    import android.webkit.WebViewClient; 

    import com.google.android.gms.ads.AdRequest; 
    import com.google.android.gms.ads.AdView; 

    public class MainActivity extends AppCompatActivity { 

     private static final String TAG = "MainActivity"; 

     private AdView mAdView; 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_main); 

      mAdView = (AdView) findViewById(R.id.adView); 
      AdRequest adRequest = new AdRequest.Builder().build(); 
      mAdView.loadAd(adRequest); 

      WebView myWebView = (WebView) findViewById(R.id.myWebView); 

      myWebView.getSettings().setJavaScriptEnabled(true); 
      myWebView.getSettings().setUseWideViewPort(true); 
      myWebView.getSettings().setLoadWithOverviewMode(true); 
      myWebView.getSettings().setDomStorageEnabled(true); 
      myWebView.loadUrl("https://spanish.netfoxplus.com"); 
      myWebView.setWebViewClient(new MyWebViewClient()); 
      WebSettings webSettings = myWebView.getSettings(); 
      webSettings.setJavaScriptEnabled(true); 

     } 

     private class MyWebViewClient extends WebViewClient { 

      @Override 

      public boolean shouldOverrideUrlLoading(WebView view, String url) { 

       if (Uri.parse(url).getHost().equals("spanish.netfoxplus.com")) { 

        return false; 

       } 

       else { 

        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 

        startActivity(intent); 

        return true; 
       } 
      } 
     } 

     @Override 
     public boolean onKeyDown(int keyCode, KeyEvent event) { 
    // Check if the key event was the Back button and if there's history 
      WebView myWebView = (WebView) findViewById(R.id.myWebView); 
      if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) { 
       myWebView.goBack(); 
       return true; 
      } 
    // If it wasn't the Back key or there's no web page history, bubble up to the default 
    // system behavior (probably exit the activity) 
      return super.onKeyDown(keyCode, event); 
     } 
+0

你有這個在你的AndroidManifest.xml'機器人:screenOrientation = 「肖像」>'? – Steven

+0

是的,但不要做任何事 – antoniovm99

+0

如果有,你將無法全屏播放視頻,因爲你的屏幕鎖定爲肖像 – Steven

回答

0

添加這段代碼的網頁視圖!

webView.getSettings().setUserAgentString("Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 

字完全在android系統7.0