使用YouTube Player API,以特定用户身份播放视频,并应用YouTube Red订阅 [英] Using YouTube Player API, play video as a specific user, applying YouTube Red subscription

查看:142
本文介绍了使用YouTube Player API,以特定用户身份播放视频,并应用YouTube Red订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用适用于Android的YouTube Player API 1.2.2播放视频.但是,即使订阅了YouTube Red,用户仍会始终看到片头广告.为了利用YouTube Red订阅(这会禁用广告),我没有找到关于特定YouTube用户的有关视频播放的任何文档.

I am able to play videos using the YouTube Player API 1.2.2 for Android. However, users always see pre-roll ads even if they have a YouTube Red subscription. I could not find any documentation surrounding video playback as a specific YouTube user, in order to take advantage of a YouTube Red subscription, which disables ads.

YouTubePlayerSupportFragment.initialize()的Javadoc说:

The javadoc for YouTubePlayerSupportFragment.initialize() says:

public void 初始化(字符串developerKey,YouTubePlayer.OnInitializedListener侦听器)

public void initialize (String developerKey, YouTubePlayer.OnInitializedListener listener)

初始化YouTubePlayer,可用于播放视频和控制视频播放.初始化成功或失败时,将调用侦听器中的回调之一.

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.

参数

developerKey 有效的API密钥,已启用以使用YouTube数据API v3服务.要生成新密钥,请访问Google Developers Console.
listener 初始化成功或失败时将调用的回调.

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密钥,而不是用户的OAuth凭据.有什么方法可以代替传递OAuth凭据,以特定用户的身份播放视频吗?

So it takes an API key, rather than a user's OAuth credentials. Is there any way to pass the OAuth credentials instead, to play a video as a specific user?

我看到了这个示例应用程序: https://github.com/youtube/yt -direct-lite-android -它显示了一个使用OAuth 2.0来上传视频的示例,但是播放仅使用一个简单的API密钥.

I saw this example app: https://github.com/youtube/yt-direct-lite-android -- It shows an example of using OAuth 2.0 to upload videos, but the playback uses a simple API key only.

推荐答案

除使用WebView之外,目前尚没有一种以特定用户身份播放视频的方法.它与使用YouTube上的YoutubePlayerView播放私人YouTube视频的答案相同?:

There is not currently a way to play videos as a specific user, aside from using WebView. It is the same as the answer to Play private YouTube video using YoutubePlayerView from YoutubeAndroidPlayerAPI?:

使用Android Player API无法做到这一点.在设备上播放私人视频的唯一方法是在您的应用中实现WebView,让用户登录其YouTube帐户,然后仅在该特定浏览器会话中播放私人视频.

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.

这篇关于使用YouTube Player API,以特定用户身份播放视频,并应用YouTube Red订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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