如何在Android中播放.flv视频?

时间:2011-12-22 09:58:27

标签: java javascript android

我正在尝试在Android中播放Flash视频,但它无效。这里我在我的Android应用程序中使用了WebView,但它有一个问题。我已经展示了代码:

    WebView wbView=(WebView)findViewById(R.id.webView);
    wbView.getSettings().setJavaScriptEnabled(true);
    String htmlCode="<html>" +
                    "<head>" +
                    "<script src='http://www.exapmle.com/video/swfobject.js' type='text/javascript'></script>" +
                    "</head>" +
                    "<body>" +
                    "<div id='flvplayer'><img src='http://www.exapmle.com/video/trusted.jpg'></div>" +
                    "<script type='text/javascript'>" +
                    "var so = new SWFObject('http://www.exapmle.com/video/TrustedComputing_LAFKON_LOW.flv', 'swfplayer', '400', '327', '9', '#000000');" +
                    "so.addVariable('flv', 'http://www.exapmle.com/video/TrustedComputing_LAFKON_LOW.flv');" +
                    "so.addVariable('jpg','http://www.exapmle.com/video/trusted.jpg');" +
                    "so.addVariable('autoplay','false');" +
                    "so.addVariable('backcolor','000000');" +
                    "so.addVariable('frontcolor','ffffff');" +
                    "so.write('flvplayer');" +
                    "</script>" +
                    "</body>" +
                    "</html>";
    wbView.loadData(htmlCode, "text/html", null);

1 个答案:

答案 0 :(得分:0)

这行代码看起来有点奇怪

"<script src='http://www.exapmle.com/video/swfobject.js' type='text/javascript'></script>"

我确定你是否确定从教程网站复制它。您需要在某个域上托管swfobject.js,然后将其实现到您的htmlcode中。 swfobject.js使SWFObject可用:

var so = new SWFObject(...)