YouTube IFRAME与YouTube Android Player API [英] YouTube IFRAME vs YouTube Android Player API

查看:126
本文介绍了YouTube IFRAME与YouTube Android Player API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正计划在我的Android应用中安装YouTube播放器,并找到了两种选择: IFRAME API 或使用 YouTube Android Player API .到目前为止,我找不到比较这两种方法的参考.

I am planning on having a YouTube player in my android app and found two alternatives: IFRAME API or with YouTube Android Player API. So far I don't find any reference for comparing the two approaches.

我对这两者都是陌生的,所以我没有很好的背景来比较两者.到目前为止,这是我所知道的:

I am new to both so I don't have a good background to compare both (yet). But so far this is what I know:

框架

  • 专业人士:无需获取开发人员/应用程序密钥即可访问API.
  • 专业人士:无需包括YouTubePlayer API的jar(无需增加APK大小)
  • 缺点:不必要的webview和javascript胶水代码可以连接

YT Player API:

YT Player API:

  • 专业人士:本机Java,无需javascript胶水代码
  • 缺点:需要在设备上使用YouTube应用
  • 缺点:需要获取开发者/应用密钥,并且需要将API jar包含到您的APK中.

同时使用它们,我还不知道两者之间的性能/内存使用情况.我也不知道相对于IFRAME,我们是否可以通过API获得更详细的事件. 我正在尝试评估这些内容,但想听听你们中是否有人对此有意见.

Playing with both, I don't know yet any perf/memory usage between the two. I also don't know if we can have more detailed events from the API vs through IFRAME. I am trying to assess these but would like to hear if any of you have opinions on these.

谢谢

推荐答案

Here you can find a few reason for not using the YouTube Player API.

总体来说,如果需要做一些基本的事情(例如使用YouTubeBaseActivity/YouTubeStandalonePlayer),则可以放心使用.如果您需要使用YouTubePlayerFragment,则基于WebView的方法可能是一个更好的主意.

Overall I'd say: if need to do basic stuff (like using YouTubeBaseActivity/YouTubeStandalonePlayer) you can safely use it. If you need to use the YouTubePlayerFragment a WebView based approach may be a better idea.

您为什么应该考虑不使用YouTube的官方库?

  • If you’re concerned about stability: The YouTube Android Player API is not the best API ever designed. You are probably going to be fine if you need to use the YouTubeBaseActivity/YouTubeStandalonePlayer, but you’re going to run into issues with the YouTubePlayerFragment. The library has some very old bugs, this one is the most significant I have encountered. While developing my app I kept running into it, seeing my app randomly crash for apparently no reason. It made my app unstable and never ready for production. The bug is still there, as far as I know. A new version of the library should be in the making, but it has yet to be released.

如果您不想被Google Play和YouTube应用所束缚, 为了运行使用YouTube Android Player API的应用,设备需要同时安装Google Play和YouTube应用的最新版本. 在大多数情况下,这可能不是一个限制,因为您可能要通过Google Play分发应用.但我已经与遇到此问题的人进行过交谈,也许您也对此有所关注.

If you don’t want to be tied to Google Play and the YouTube app: In order to run an app that utilizes the YouTube Android Player API a device needs to have both Google Play and the last version of the YouTube app installed. This may not be a limitation in most cases, since you’re probably going to distribute your app through Google Play. But I have talked with people that had this problem, maybe you care about it as well.

如果要进一步控制播放器的外观和行为,请执行以下操作: YouTube Android Player API不是开源的,因此您可以进行自定义,只要API允许.也许您想更改播放器的UI或编写一些针对您的用例的自定义行为.官方图书馆很难做到这一点.

If you want more control over the player looks and behavior: The YouTube Android Player API is not open source, therefore the customization you can do goes as far as the API allows to. Maybe you want to change the UI of the player or write some custom behavior specific for your use cases. That is going to be hard to do with the official library.

如果您不想在Google Developers Console中注册您的应用

这篇关于YouTube IFRAME与YouTube Android Player API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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