1

我有一个可行的解决方案来在 android 手机中查看 HTML5 视频。它在安卓平板电脑上根本不起作用(例如三星 Galaxy Tab 2)。当我开始播放视频时,我可以听到声音,但屏幕是黑色的。

这是我的代码: http: //pastebin.com/P9ebDKha

我必须重写所有代码吗?小错误?

4

1 回答 1

0

THis is how i am getting to play a youtube video filling the size of the webview which i have ...

               video = (WebView) v.findViewById(R.id.videoview);

               String videoURL = "http://www.youtube.com/v/DZi6DEJsOJ0?fs=1&hl=nl_NL";

               video.setHorizontalScrollBarEnabled(false);
               video.setVerticalScrollBarEnabled(false);

               video.getSettings().setJavaScriptEnabled(true);
               video.getSettings().setPluginsEnabled(true);

               Display display = getActivity().getWindowManager().getDefaultDisplay();
               int width = display.getWidth();
           int widthdp = (int) (width / getResources().getDisplayMetrics().density);
               int height = display.getHeight();
          int heightdp = (int) (height / getResources().getDisplayMetrics().density);


               String widthAndHeight = "width=" + widthdp + "height=" + heightdp;
               String temp = "<object "
              + widthAndHeight
               + ">"
            + "<body style='margin:0;padding:0;'>"
          + "<param name='allowFullScreen' value='true'>"
          + "</param><param name='allowscriptaccess' value='always'>"
           + "</param><embed src='"
           + videoPoP
            + "'"
             + " type='application/x-shockwave-flash' style='margin:0;padding:0;'         allowscriptaccess='always' allowfullscreen='true'"
                + widthAndHeight + "></embed></object>";

               video.loadData(temp, "text/html", "utf-8");
于 2012-07-27T20:25:22.893 回答