最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

Android如何让WebView中的HTML5页面实现视频全屏播放

IT圈 admin 26浏览 0评论

2024年6月14日发(作者:蒲雨南)

public class WebViewActivity extends AppCompatActivity {

private FrameLayout mFrameLayout;

private WebView mWebView;

private MyWebChromeClient mMyWebChromeClient;

private String URL = "/20130704/";

@Override

protected void onCreate(Bundle savedInstanceState) {

requestWindowFeature(E_NO_TITLE);

te(savedInstanceState);

setContentView(ty_webview);

mFrameLayout = (FrameLayout) findViewById(Layout);

mWebView = (WebView) findViewById(ew);

initWebView();

l(URL);

}

private void initWebView() {

WebSettings settings = tings();

aScriptEnabled(true);

aScriptCanOpenWindowsAutomatically(true);

ginState();

owFileAccess(true);

dWithOverviewMode(true);

WideViewPort(true);

heMode(_NO_CACHE);

heMode(_DEFAULT);

mMyWebChromeClient = new MyWebChromeClient();

ChromeClient(mMyWebChromeClient);

ViewClient(new WebViewClient() {

public boolean shouldOverrideUrlLoading(WebView view, String url) {

l(url);

return true;

}

@Override

public void onPageFinished(WebView view, String url) {

Finished(view, url);

}

});

}

private class MyWebChromeClient extends WebChromeClient {

private View mCustomView;

private CustomViewCallback mCustomViewCallback;

@Override

public void onShowCustomView(View view, CustomViewCallback callback) {

CustomView(view, callback);

if (mCustomView != null) {

omViewHidden();

return;

}

mCustomView = view;

w(mCustomView);

mCustomViewCallback = callback;

ibility();

setRequestedOrientation(_ORIENTATION_LANDSCAPE);

}

public void onHideCustomView() {

ibility(E);

if (mCustomView == null) {

return;

}

ibility();

View(mCustomView);

omViewHidden();

mCustomView = null;

setRequestedOrientation(_ORIENTATION_PORTRAIT);

CustomView();

}

}

@Override

public void onConfigurationChanged(Configuration config) {

igurationChanged(config);

switch (ation) {

case ATION_LANDSCAPE:

getWindow().clearFlags(_FORCE_NOT_FULLSCREEN);

2024年6月14日发(作者:蒲雨南)

public class WebViewActivity extends AppCompatActivity {

private FrameLayout mFrameLayout;

private WebView mWebView;

private MyWebChromeClient mMyWebChromeClient;

private String URL = "/20130704/";

@Override

protected void onCreate(Bundle savedInstanceState) {

requestWindowFeature(E_NO_TITLE);

te(savedInstanceState);

setContentView(ty_webview);

mFrameLayout = (FrameLayout) findViewById(Layout);

mWebView = (WebView) findViewById(ew);

initWebView();

l(URL);

}

private void initWebView() {

WebSettings settings = tings();

aScriptEnabled(true);

aScriptCanOpenWindowsAutomatically(true);

ginState();

owFileAccess(true);

dWithOverviewMode(true);

WideViewPort(true);

heMode(_NO_CACHE);

heMode(_DEFAULT);

mMyWebChromeClient = new MyWebChromeClient();

ChromeClient(mMyWebChromeClient);

ViewClient(new WebViewClient() {

public boolean shouldOverrideUrlLoading(WebView view, String url) {

l(url);

return true;

}

@Override

public void onPageFinished(WebView view, String url) {

Finished(view, url);

}

});

}

private class MyWebChromeClient extends WebChromeClient {

private View mCustomView;

private CustomViewCallback mCustomViewCallback;

@Override

public void onShowCustomView(View view, CustomViewCallback callback) {

CustomView(view, callback);

if (mCustomView != null) {

omViewHidden();

return;

}

mCustomView = view;

w(mCustomView);

mCustomViewCallback = callback;

ibility();

setRequestedOrientation(_ORIENTATION_LANDSCAPE);

}

public void onHideCustomView() {

ibility(E);

if (mCustomView == null) {

return;

}

ibility();

View(mCustomView);

omViewHidden();

mCustomView = null;

setRequestedOrientation(_ORIENTATION_PORTRAIT);

CustomView();

}

}

@Override

public void onConfigurationChanged(Configuration config) {

igurationChanged(config);

switch (ation) {

case ATION_LANDSCAPE:

getWindow().clearFlags(_FORCE_NOT_FULLSCREEN);

发布评论

评论列表 (0)

  1. 暂无评论