我可以使用适用于 Android 的 YouTube Player API 1.2.2 播放视频。但是,即使订阅了 YouTube Red,用户也总会看到前贴片广告。我找不到任何有关作为特定 YouTube 用户播放视频的文档,以便利用禁用广告的 YouTube Red 订阅。YouTubePlayerSupportFragment.initialize()
的 javadoc说:
public void initialize (String developerKey, YouTubePlayer.OnInitializedListener listener)
Initialize a YouTubePlayer, which can be used to play videos and control video playback. One of the callbacks in listener will be invoked when the initialization succeeds or fails.
Parameters
developerKey A valid API key that is enabled to use the YouTube Data API v3 service. To generate a new key, visit the Google Developers Console.
listener The callbacks that will be invoked when the initialization succeeds or fails.
所以它需要一个 API key ,而不是用户的 OAuth 凭据。有没有办法传递 OAuth 凭据,以特定用户身份播放视频?
我看到了这个示例应用程序:https://github.com/youtube/yt-direct-lite-android -- 它显示了使用 OAuth 2.0 上传视频的示例,但播放仅使用简单的 API key 。
最佳答案
除了使用 WebView 之外,目前没有办法以特定用户的身份播放视频。与 Play private YouTube video using YoutubePlayerView from YoutubeAndroidPlayerAPI? 的答案相同:
This is not possible with the Android Player API. The only way to play private videos on a device is to implement a WebView in your app, have the user log into their YouTube account, and then play back the Private video in that specific browser session only.
关于android - 使用 YouTube Player API,以特定用户身份播放视频,应用 YouTube Red 订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45604832/