如何在我的 Android 选项卡中创建 YouTube 应用程序?
由于我没有 Flash 播放器来播放 Youtube 本身的视频,因此我需要在默认的 MediaPlayer 中播放它。我使用的代码如下:
MediaController mc = new MediaController(ctx);
setContentView(R.layout.main);
vv = (VideoView) findViewById(R.id.VideoView01);
try {
ur = Uri.parse(Url /*+ "&fmt=18"*/); // "&fmt=18"to convert to mp4
System.out.println("Host = " + ur.getHost());
System.out.println("Encoded Path = " + ur.getEncodedPath());
vv.setVideoURI(ur);
// vv.setVideoPath("http://www.daily3gp.com/vids/747.3gp");
vv.setMediaController(mc);
vv.requestFocus();
vv.start();
mc.show();
} catch (Exception ex) {
System.out.println("Exception!!!!!!!!!!!!!!!! "
+ ex.getMessage());
}
问题是......它正在获取链接,当我们将链接提供给播放器时,它说“此视频无法播放......
请帮忙!!!!!!” !!!!!!
Since I don't have a flash player to play the video from Youtube itself, I need to play it in my default MediaPlayer. The code I used is as follows:
MediaController mc = new MediaController(ctx);
setContentView(R.layout.main);
vv = (VideoView) findViewById(R.id.VideoView01);
try {
ur = Uri.parse(Url /*+ "&fmt=18"*/); // "&fmt=18"to convert to mp4
System.out.println("Host = " + ur.getHost());
System.out.println("Encoded Path = " + ur.getEncodedPath());
vv.setVideoURI(ur);
// vv.setVideoPath("http://www.daily3gp.com/vids/747.3gp");
vv.setMediaController(mc);
vv.requestFocus();
vv.start();
mc.show();
} catch (Exception ex) {
System.out.println("Exception!!!!!!!!!!!!!!!! "
+ ex.getMessage());
}
The thing is....It is getting the link and when we give the link to the player, it say's This Video cannot be Played.....
Please help !!!!!!!!!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 CommonsWare 所说:play-youtube-video-in-webview
您无法将它们显示为嵌入的,除非在具有 Flash 的设备上。
但是,如果您可以解析 YouTube 视频详细信息,则可以构建一个
ACTION_VIEW
Intent
将其显示在 YouTube 应用程序上...适用于那些 Android 设备具有 YouTube 应用程序的。希望这有帮助。
As CommonsWare said here: play-youtube-video-in-webview
You cannot show them embedded except perhaps on devices that have Flash.
However, if you can parse out the YouTube video details, you may be able to construct an
ACTION_VIEW
Intent
that will show them on the YouTube application...for those Android devices that have the YouTube application.Hope this helps.
尝试这可能对你有用
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")));
try this may be useful to u
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")));
起初,我提供的下载网址不正确。现在,它正在工作......
Atfirst, the URL that I gave for download was incorrect. Now, it is working...