强制视频在 Android 上的 Youtube 应用程序中打开 [英] Force video to open in Youtube app on Android

查看:21
本文介绍了强制视频在 Android 上的 Youtube 应用程序中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个链接到 YouTube 视频的移动网站.在 Android 上,点击此链接会弹出一个对话框,要求用户使用"他们的浏览器或 Youtube 应用完成操作".

I have a mobile website that links to a youtube video. On Android, clicking on this link brings up a dialog asking the user to "Complete action using" their browser or the Youtube app.

有没有办法绕过这个屏幕,直接在 Youtube 应用中播放视频?(例如使用 youtube://网址.)

Is there a way to bypass this screen and just play the video in the Youtube app? (For example with a youtube:// URL.)

谢谢!

推荐答案

您可以这样做:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + id));
startActivity(intent);

id 是 url 中问号后的标识符.例如:youtube.com/watch?v=ID

The id is the identifier after the questionmark in the url. For example: youtube.com/watch?v=ID

另一种方式是:

Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setData(url);
videoIntent.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
startActivity(videoIntent);

......

这篇关于强制视频在 Android 上的 Youtube 应用程序中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆