how to set to play only HD Videos in YouTube Android Player API(如何在 YouTube Android Player API 中设置仅播放高清视频)
问题描述
如何让 YouTube Android Player API 播放只播放高清视频 Link
How to make YouTube Android Player API play only HD Videos Link
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
Log.v("Mobile Url", "" + mobile_url);
player.loadVideo(mobile_url);
player.setFullscreen(true);
player.setShowFullscreenButton(false);
player.loadVideo("N1nFoVI3xJM");
}
}
这里我可以设置loadVideo
、setFullscreen
、setShowFullscreenButton
我需要只加载高清视频.那可能吗?有什么方法可以设置只播放高清视频吗?如果没有找到该 ID 的高清视频,那么我需要显示 toast,因为现在正在播放非高清视频如何执行此操作,请提供一些想法或建议以实现此概念
Here I can set the loadVideo
, setFullscreen
, setShowFullscreenButton
I need to load only HD Videos. Is that possible? Is any method available to set play only HD videos? If no HD Video found for that ID then I need to show toast as now playing non-HD Videos how to perform this please give some idea or suggestion to achieve this concept
推荐答案
可以使用:player.setPlaybackQuality(suggestedQuality:String):Void
来自 YouTube API 文档:
From the YouTube API docs:
此函数设置当前视频的建议视频质量.该函数使视频在其当前位置重新加载新品质.如果播放质量确实改变了,它只会改变对于正在播放的视频.调用此函数并不能保证播放质量实际上会改变.但是,如果播放质量确实发生了变化,onPlaybackQualityChange 事件将火,你的代码应该响应事件而不是事实它调用了 setPlaybackQuality 函数.
This function sets the suggested video quality for the current video. The function causes the video to reload at its current position in the new quality. If the playback quality does change, it will only change for the video being played. Calling this function does not guarantee that the playback quality will actually change. However, if the playback quality does change, the onPlaybackQualityChange event will fire, and your code should respond to the event rather than the fact that it called the setPlaybackQuality function.
这篇关于如何在 YouTube Android Player API 中设置仅播放高清视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 YouTube Android Player API 中设置仅播放高清视频
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- URL编码Swift iOS 2022-01-01
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- UITextView 内容插图 2022-01-01
- GPS状态的广播接收器? 2022-01-01