如何使用loadDataWithBaseURL播放嵌入视频

时间:2013-03-21 09:02:56

标签: java android video video-streaming

问题描述

我试图通过调用loadDataWithBaseURL方法并传递给它嵌入数据来播放SWF视频。但视频不会开始播放,只显示白屏。我做错了吗?

源代码

protected void onCreate(Bundle savedInstanceState) {
    // Get Web View from the layout.
    mWebView = (WebView) findViewById(R.id.webViewOnlieWebCams);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setPluginsEnabled(true);
    mWebView.getSettings().setAllowFileAccess(true);

    String mimeType = "text/html";  
    String encoding = "utf-8";  
    String embed = "<embed type=\"application/x-shockwave-flash\" src=\"/bundles/mymain/swf/player-licensed.swf\" width=\"320\" height=\"390\" style=\"undefined\" id=\"mpl\" name=\"mpl\" quality=\"low\" allowfullscreen=\"true\" allowscriptaccess=\"always\" wmode=\"opaque\" flashvars=\"autostart=true&amp;file=camera39.stream&amp;streamer=rtmp://wss.yerevan.am/axis&amp;logo=/bundles/mymain/images/logo10.png&amp;logo.hide=false&amp;logo.position=bottom-left&amp;logo.timeout=3\">";

    mWebView.loadDataWithBaseURL(null, embed, mimeType, encoding, "");      
}

1 个答案:

答案 0 :(得分:2)

尝试使用以下代码:

String html = "<object width=\"1008\"height=\"550\"> <param name=\"movie\" value=\"file://"
                        + path
                        + "\"> <embed src=\"file://"
                        + path
                        + "\" width=\"1008\"height=550\"> </embed> </object>";
                String mimeType = "text/html";
                String encoding = "utf-8";
                web.loadDataWithBaseURL("null", html, mimeType, encoding, "");