Android YouTube 应用播放视频意图

编程入门 行业动态 更新时间:2024-10-23 16:20:13
本文介绍了Android YouTube 应用播放视频意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个应用程序,您可以在其中下载适用于 Android 的 YouTube 视频.现在,我想要它,如果你在 YouTube 原生应用中播放视频,你也可以下载它.为此,我需要知道 YouTube 原生应用为了播放 YouTube 应用而推出的 Intent.如果我的模拟器上有 YouTube 程序,我可以轻松地做到这一点,所以我的第一个问题是:1. 我可以为我的模拟器下载 YouTube 应用程序,或者...2. 用户选择视频播放时使用的意图是什么.

I have created a app where you can download YouTube videos for android. Now, I want it so that if you play a video in the YouTube native app you can download it too. To do this, I need to know the Intent that the YouTube native app puts out in order to play the YouTube app. I could do this easially if I had the YouTube program on my emulator, so my 1st question is: 1. Can I download the YouTube app for my emulator, or... 2. What is the intent used when the user selects a video for playback.

推荐答案

这个怎么样:

public static void watchYoutubeVideo(Context context, String id){ Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + id)); Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("www.youtube/watch?v=" + id)); try { context.startActivity(appIntent); } catch (ActivityNotFoundException ex) { context.startActivity(webIntent); } }

更多推荐

Android YouTube 应用播放视频意图

本文发布于:2023-11-23 13:55:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621672.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:意图   视频   Android   YouTube

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!