2013-03-18 121 views
0

我在我的应用程序语句的Android无法启动视频活动

Uri uri = Uri.parse(movie1.getMovieWatchLink()); 
// With this line the Youtube application, if installed, will launch immediately. 
// Without it you will be prompted with a list of the application to choose. 
uri = Uri.parse("vnd.youtube:"+ uri.getQueryParameter("v")); 
Intent intent = new Intent("android.intent.action.VIEW", uri); 
VideoActivity.this.startActivity(intent); 

我通过YouTube视频网址

当我运行上面的语句

,我不能够启动的活动,任何人都可以帮助我吗?

+0

你有没有记录? – AAnkit 2013-03-18 05:44:52

+0

是的,我调试它停止VideoActivity.this.startActivity(intent); – String 2013-03-18 05:45:54

+0

发布您的VideoActivity代码.. – Subburaj 2013-03-18 05:52:49

回答

0

您可以使用此代码内部的WebView来使用loadURL

<iframe width="560" height="315" src="http://www.youtube.com/embed/...." frameborder="0"  allowfullscreen></iframe> 
0

你可以试试这个:

public class VideoWebview 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&[email protected]@' " + 
      " 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.videowebview); 

      String url= "Your url"; 
     System.out.println("url="+url); 

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

     webView.getSettings().setJavaScriptEnabled(true); 
     webView.getSettings().setAllowFileAccess(true); 
     webView.getSettings().setPluginsEnabled(true); 
     webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); //thanks Patrick! 

     htmlCode = htmlCode.replaceAll("@[email protected]",url); 
     webView.loadDataWithBaseURL("fake://fake/fake", htmlPre+htmlCode+htmlPost, "text/html", "UTF-8", null); 
    }