Cannot use jwplayer in an Android app

谁说胖子不能爱 提交于 2019-12-05 11:40:00

U can refer below code and do it..i hope this example help u to out of this..

 private void createVideoHtml(File flvDirectory, File htmlFile, String videofilename)
{
    String htmlPre = "<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"></head><body style='margin:0; padding:0;'>";  
    String htmlCode =
            "<script type='text/javascript' src='"+ flvDirectory.getAbsolutePath() + "/jwplayer.js'></script>" +
            "<div id='mediaspace'>EZ Stream TV FLV Player</div>" +
            "<script type='text/javascript'>" +
            "jwplayer('mediaspace').setup({" +
            "'flashplayer': '"+ flvDirectory.getAbsolutePath() + "/player.swf', 'file': '" + videofilename + "', 'backcolor': 'FFFFFF', 'frontcolor': '000000', 'lightcolor': '000000'," +
            "'screencolor': '000000', 'volume': '100', 'autostart': 'true', 'mute': 'false', 'quality': 'false', 'controlbar': 'bottom', 'width': '100%', 'height': '100%'," +
            "events: { " +
            "onComplete: function() { alert('COMPLETED');}" +
            "}});" +
            "</script>";
    String htmlPost = "</body></html>";
    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;
        }
    });
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!