2012-07-27 66 views

回答

2

嗨檢查這個link它有一個代碼播放你管視頻使用網絡視圖它可能會幫助您的要求。

+0

謝謝,我會嘗試。 – 2012-07-27 13:38:41

0

我這是怎麼得到發揮YouTube視頻填充,我有web視圖的大小...

   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"); 
+0

只是一個簡短的提示:用''+''方法連接字符串的速度非常慢。使用StringBuffer或StringBuilder代替:-) – 2012-07-27 20:51:08