VideoView
并且Mediaplayer
只能播放文档Android Supported Media Formats中给出的格式。
您提供的 YouTube 视频链接用于HTML 页面。如果您正在播放 Karthik 提到的 HTML 页面,最好使用Webview
.
String url = "your_youtube_link";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
如果您只想从该链接查看视频,请在页面中保留所有其他详细信息。假设这是 YouTube 链接http://www.youtube.com/watch?v=ZC7ZOGpM2cU&feature=g-logo&context=G233b464FOAAAAAAABAA
如果您解析 YouTube HTML 页面的源代码,您可能会看到以下部分:
<link rel="alternate" type="application/json+oembed" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3DZC7ZOGpM2cU&format=json" title="Bigg Boss 5: Juhi Parmar wins Big Boss season 5">
<link rel="alternate" type="text/xml+oembed" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3DZC7ZOGpM2cU&format=xml" title="Bigg Boss 5: Juhi Parmar wins Big Boss season 5">
<meta property="fb:app_id" content="87741124305">
<meta property="og:url" content="http://www.youtube.com/watch?v=ZC7ZOGpM2cU">
<meta property="og:title" content="Bigg Boss 5: Juhi Parmar wins Big Boss season 5">
<meta property="og:description" content="Ntv News: Juhi Parmar wins Bigg Boss 5 - Juhi Parmar wins 'Bigg Boss 5', takes home Rs.1 crore - No kid for now, keen for good work: Juhi Parmar">
<meta property="og:type" content="video">
<meta property="og:image" content="http://i3.ytimg.com/vi/ZC7ZOGpM2cU/hqdefault.jpg">
<meta property="og:video" content="http://www.youtube.com/v/ZC7ZOGpM2cU?version=3&autohide=1">
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="396">
<meta property="og:video:height" content="297">
<meta property="og:site_name" content="YouTube">
在此,提取以下内容
<meta property="og:video" content="http://www.youtube.com/v/ZC7ZOGpM2cU?version=3&autohide=1">
在此,<http://www.youtube.com/v/ZC7ZOGpM2cU?version=3&autohide=1>
链接将全屏显示。