YouTube IFRAME vs YouTube Android Player API

£可爱£侵袭症+ 提交于 2020-02-04 05:04:09

问题


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:

IFRAME

  • Pro: Don't need to get Developer/App Key to access the API.
  • Pro: Don't need to include YouTubePlayer API's jar (don't increase your APK size)
  • Con: Unnecessary webview and javascript glue code to hook up

YT Player API:

  • Pro: Native Java, no need of javascript glue code
  • Con: Need YouTube app on the device
  • Con: Need to get Developer/App Key and need to include the API jar to your APK.

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.

Thank you


回答1:


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

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.

Why should you consider not using the official library from 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.

  • 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.

  • 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.

  • If you don’t want to register your app in the Google Developers Console



来源:https://stackoverflow.com/questions/51678030/youtube-iframe-vs-youtube-android-player-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!