如何选择YouTube视频的质量?

时间:2015-07-02 10:09:02

标签: ios objective-c youtube-api

如何下​​载和播放具有不同质量值的YouTube视频,例如"高," "低,"和"正常"?

2 个答案:

答案 0 :(得分:0)

你可以使用PSYouTubeExtractor.h类它可以获取youtube mp4视频网址,而不是下载和查看不是问题

以下是我的示例“Project

同时检查此Github项目herehere

答案 1 :(得分:0)

使用YouTube的iOS Player Helper class(YTPlayerView),您可以按建议的质量值加载视频;

ViewController.m

@property (weak, nonatomic) IBOutlet YTPlayerView *playerView;

// ...

[self.playerView loadVideoById:@"zN-GGeNPQEg" startSeconds:0.0f suggestedQuality:kYTPlaybackQualitySmall];

YTPlayerView.h中的质量选项:

/** These enums represent the resolution of the currently loaded video. */
typedef NS_ENUM(NSInteger, YTPlaybackQuality) {
    kYTPlaybackQualitySmall,
    kYTPlaybackQualityMedium,
    kYTPlaybackQualityLarge,
    kYTPlaybackQualityHD720,
    kYTPlaybackQualityHD1080,
    kYTPlaybackQualityHighRes,
    kYTPlaybackQualityAuto, /** Addition for YouTube Live Events. */
    kYTPlaybackQualityDefault,
    kYTPlaybackQualityUnknown /** This should never be returned. It is here for future proofing. */
};

请勿使用Auto,该值仅适用于直播活动播放。