JWPlayer Javascript API for Android Webview

前端 未结 2 1013
[愿得一人]
[愿得一人] 2021-02-07 01:56

I\'m trying to get JWPlayer to return an alert when a few specific events happen from a flash player playing a local video. If you notice from the code below, onComplete, JWPlay

2条回答
  •  隐瞒了意图╮
    2021-02-07 02:24

    You can refer to the code below for JWPlayer to Webview

    private void createVideoHtml(File flvDirectory, File htmlFile, String videofilename)
    {
        String htmlPre = "";  
        String htmlCode =
            "" +
            "
    EZ Stream TV FLV Player
    " + ""; String htmlPost = ""; String finalHTML = htmlPre + htmlCode + htmlPost; try { FileWriter f = new FileWriter(htmlFile); PrintWriter p = new PrintWriter(f); p.print(finalHTML); p.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } webView = (WebView)findViewById(R.id.web_player); webView.getSettings().setBuiltInZoomControls(false); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadsImagesAutomatically(true); webView.getSettings().setPluginsEnabled(true); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webView.getSettings().setAllowFileAccess(true); webView.setInitialScale(60); webView.setBackgroundColor(Color.BLACK); getWindow().addFlags(128); webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)"); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, final android.webkit.JsResult result) { Log.d(TAG, message); new AlertDialog.Builder(view.getContext()).setMessage(message).setCancelable(true).show(); result.confirm(); return true; } });

提交回复
热议问题