2012-11-27 5 views
0

이 질문은 여러 번 묻습니다. 그러나 해결 방법이 없습니다. 내가하려는 일은 매우 간단합니다. URL을 지정하고로드하고 싶습니다. WebView에있는 URL입니다. 동영상에 URL이 있습니다. 재생 버튼을 클릭하면 아무 것도 재생되지 않습니다. 다음클릭하면 Android WebView가 재생되지 않습니다.

은 나를 위해 작동, 내가 지금까지 시도 내 코드,

public class MoviesActivity extends Activity { 

    WebView mWebView; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 

     // Adds Progrss bar Support 
     this.getWindow().requestFeature(Window.FEATURE_PROGRESS); 
     setContentView(R.layout.webview); 

     // Makes Progress bar Visible 
     getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); 

     // Get Web view 
     mWebView = (WebView) findViewById(R.id.webView1); //This is the id you gave 
     if (Build.VERSION.SDK_INT < 8) { 
      mWebView.getSettings().setPluginsEnabled(true); 
     } else { 
      mWebView.getSettings().setPluginState(PluginState.ON); 
     } 

      //to the WebView in the main.xml 
     mWebView.getSettings().setJavaScriptEnabled(true); 
     mWebView.getSettings().setSupportZoom(true);   //Zoom Control on web (You don't need this 
     // mWebView.getSettings().setPluginsEnabled(true);             //if ROM supports Multi-Touch  
     mWebView.getSettings().setBuiltInZoomControls(true); //Enable Multitouch if supported by ROM 
     // Load URL 



     // Sets the Chrome Client, and defines the onProgressChanged 
     // This makes the Progress bar be updated. 
     final Activity MyActivity = this; 
     mWebView.setWebChromeClient(new WebChromeClient() { 
     public void onProgressChanged(WebView view, int progress) 
     { 
      //Make the bar disappear after URL is loaded, and changes string to Loading... 
      MyActivity.setTitle("Loading..."); 
      MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded 

      // Return the app name after finish loading 
      if(progress == 100) 
       MyActivity.setTitle(R.string.app_name); 
      } 
     }); 

     mWebView.setWebViewClient(new HelloWebViewClient()); 
     mWebView.loadUrl("http://www.youtube.com/user/africanmoviesnews"); 
     mWebView.setWebViewClient(new HelloWebViewClient()); 
    }//End of Method onCreate 
    private class HelloWebViewClient extends WebViewClient { 
     @Override 
     public boolean shouldOverrideUrlLoading(WebView view, String url) { 
      view.loadUrl(url); 
      return true; 
     } 
    } 
} 

답변

0

당신이 하나를 시도 할 수있다.

WebView video = (WebView) findViewById(R.id.video); 
String widthAndHeight = "width='220' height='200'"; 
String videoURL = "http://www.youtube.com/v/DZi6DEJsOJ0?fs=1&amp;hl=nl_NL"; 

String temp = "<object "+widthAndHeight+">" + 
"<param name='allowFullScreen' value='false'>" + 
"</param><param name='allowscriptaccess' value='always'>" + 
"</param><embed src='"+ videoURL +"'" + 
" type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true'" + widthAndHeight + 
"></embed></object>"; 

video.getSettings().setJavaScriptEnabled(true); 
video.getSettings().setPluginsEnabled(true); 
video.loadData(temp,"text/html", "utf-8"); 
+0

답장을 보내 주셔서 감사합니다. 하지만 하나의 비디오가 아닌 웹 사이트 URL을로드해야합니다.이 URL "http://www.youtube.com/user/africanmoviesnews"를 확인하십시오. 나는 분명하다. –

관련 문제