Use Youtube API in Android TV

前端 未结 3 1585
逝去的感伤
逝去的感伤 2020-12-10 07:42

I want to play youtube videos in my Android TV APP. I am also working on a Android phone/tablet APP and I was able to use Youtube Android API to play videos. But when I try

相关标签:
3条回答
  • 2020-12-10 08:07

    I have the same understanding with you. YouTube API works only smartphone YouTube app and not for Android TV YouTube app. I think if you are thinking of publishing Android TV app, you cannot use YouTube Player Android API except Intent for now. Because you should expect user installs Android TV YouTube app.

    For reference,

    • Current behavior of YouTube Android Player API is summarized here.
    • Source code which uses YouTube Intent to play YouTube video in Android TV.
    0 讨论(0)
  • 2020-12-10 08:07

    The YouTube playback API may not work on Android TV, but you can always implement your own playing mechanism in-app. Take a look at YouTube's web player API: https://developers.google.com/youtube/iframe_api_reference

    You can load a WebView in your app and from there add an iframe and JS logic to integrate with your controller.

    To interface between your JS and Java code, take a look at a project like this: https://github.com/Fleker/WebGameBridge.js for how to use the WebView APIs.

    In terms of getting data, there are also web APIs for this that you can access through your WebView.

    0 讨论(0)
  • 2020-12-10 08:31

    I've created YoutubeTV library, a wrapper for YouTube Player API Reference for iframe Embeds

    It provides a YoutubeTvView that embeds a Webview with Youtube iframe with all Javascript API available from this view.

    Also, YoutubeTvFragment holds a YoutubeTvView with a media control bar (PlaybackOverlayFragment)

    0 讨论(0)
提交回复
热议问题