简体   繁体   中英

How can I play .flv video in Android?

I am trying to play Flash video in Android but it's not working. Here I used a WebView in my Android application but it has a problem. I've shown that code:

    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);

This line of code looks a bit odd

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

I am some how sure you copied it from a tutorial site. You need to host the swfobject.js on some domain and then implement it into your htmlcode. swfobject.js makes SWFObject availble :

var so = new SWFObject(...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM