Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

how to set to play only HD Videos in YouTube Android Player API

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");
    }
}

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use: player.setPlaybackQuality(suggestedQuality:String):Void

From the YouTube API docs:

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...