YouTube IFRAME vs YouTube Android Player API
Asked Answered
E

1

4

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

Entablement answered 3/8, 2018 at 18:12 Comment(0)
R
4

Update 25 Jun 2023: The official YouTube Android Player API is now deprecated. So you must now use a solution based on an IFrame, like android-youtube-player.


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

Rooftop answered 4/8, 2018 at 5:17 Comment(1)
Does YouTube Player API have limitations (quotes)? Why does it need API key?Amoreta

© 2022 - 2024 — McMap. All rights reserved.