加载swf文件时设置Web视图区域很热

时间:2012-06-20 05:18:32

标签: android flash android-webview

好的,所以我有一个swf文件从SD卡加载到webview中。我想知道是否有人知道在页面加载后是否可以设置视图的“缩放”和位置? 然后我怎么能将视图集中在swf文件上,而无需用户放大并滚动文章的顶部。感谢。

1 个答案:

答案 0 :(得分:2)

您可以使用此代码

public class FLVplayerActivity extends Activity {
    WebView webView;
    String htmlPre = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"></head><body style='margin:0; pading:0; background-color: black;'>";  
    String htmlCode = 
            " <embed style='width:100%; height:100%' src='http://www.platipus.nl/flvplayer/download/1.0/FLVPlayer.swf?fullscreen=true&video=http://www.platipus.nl/flvplayer/download/pl-600.flv&autoplay=true' " +
            "  autoplay='true' " +
            "  quality='high' bgcolor='#000000' " +
            "  name='VideoPlayer' align='middle'" + // width='640' height='480' 
            "  allowScriptAccess='*' allowFullScreen='true'" +
            "  type='application/x-shockwave-flash' " +
            "  pluginspage='http://www.macromedia.com/go/getflashplayer' />" +
            "";
    String htmlPost = "</body></html>";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); 

        webView = (WebView)findViewById(R.id.webview);

        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setPluginsEnabled(true);

            webView.getSettings().setSupportZoom(false);
            webView.getSettings().setAppCacheEnabled(false);
            webView.getSettings().setAllowContentAccess(true);
            webView.getSettings().setCacheMode(webView.getSettings().LOAD_NO_CACHE);

        webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); //thanks Patrick!

        //webView.loadUrl("file:///android_asset/index.html");
        //htmlCode = htmlCode.replaceAll("@VIDEO@", "file:///android_asset/20051210-w50s.flv");
        webView.loadDataWithBaseURL("file:///android_asset/FLVPlayer.swf", htmlPre+htmlCode+htmlPost, "text/html", "UTF-8", null);  
    }