Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

flash player crashes when trying to enter fullscreen mode android 4.0

So I've created an android app that plays video from blip.tv and various other flash-enabled websites. I use a Webview to display the video. Here is my code:

try{
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


        view = new WebView(this);
        view.getSettings().setPluginsEnabled(true);
        view.getSettings().setPluginState(WebSettings.PluginState.ON);

        view.getSettings().setJavaScriptEnabled(true);
        view.getSettings().setLoadWithOverviewMode(true);
        view.getSettings().setUseWideViewPort(true);
        view.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        view.setScrollbarFadingEnabled(true);


        // get the html code
        String html = getIntent().getStringExtra("VIDEO_CONTENT");

        view.loadData(html, "text/html", null);
        setContentView(view);
    }
    catch(Exception e){

    }

The problem is with android 4 (Ice Cream Sandwich). When I try to put the app into full screen mode, the app crashes. The app does NOT crash on android 2.3 or 3.0 however. Any ideas to fix this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This happens in ICS because the show() method in android.webkit.PluginFullScreenHolder gets called when trying to go to fullscreen mode. This method does the following:

WebChromeClient client = mWebView.getWebChromeClient();
client.onShowCustomView(mLayout, mOrientation, mCallback);

If you do not set the WebChromeClient on your WebView, you will get an NPE.

This fixed our crash, however the WebView disappears and the fullscreen video is not shown.

See: Android ICS 4.0 Placing Flash WebView into full screen calls hideAll Method?

*** Update:

Ultimately, in order to get my WebView to play flash videos in full screen mode I had to implement the onShowCustomView() method in my WebChromeClient in a fashion similar to what was done in the source code for the Android browser. The implementation of that method that I used for inspiration was in the BaseUI class:

https://github.com/android/platform_packages_apps_browser/blob/master/src/com/android/browser/BaseUi.java

I don't fully understand exactly what is happening here. I also wish I understood why the developers on ICS decided to require this method to be implemented. I wish I knew the value, or what problem this solved. In past versions, this fullscreen mode "just worked" now it requires a lot of digging.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...