如何在 YouTube Android Player API 中设置仅播放高清视频 [英] how to set to play only HD Videos in YouTube Android Player API

查看:28
本文介绍了如何在 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");
    }
}

这里我可以设置loadVideosetFullscreensetShowFullscreenButton我需要只加载高清视频.那可能吗?有什么方法可以设置只播放高清视频吗?如果没有找到该 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 中设置仅播放高清视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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